Throwing message"Cannot compile the generated C# code."


This issue is very odd. It only happened in my box. Here at my place I've tried with other 3 computers, and only mine has the issue.
The following call was always returning null:
Assembly autoAssembly = CreatePixelShaderClass.CompileInMemory(codeString);
// FROM CodeTabsView.xaml.cs ln:396
So, I took some time reviewing the method compile in memory. Honestly I don't know my instalation wasn't detecting the System DLLS. So, the compiler service was reporting that dlls such as: "System.Core.dll", "WindowsBase.dll", "PresentationFramework.dll", "PresentationCore.dll" were not found.
So, I add an option to specify where the .NET dlls are located in the compiler option, and it's being set based on the CurrentDomain. As follows:
var path = Path.GetDirectoryName(AppDomain.CurrentDomain
                        .Where(a => !a.IsDynamic)
                        .Select(a => a.Location).FirstOrDefault());
options.CompilerOptions = string.Format("/lib:{0}", path);
I'm not sure if there is other optoin to get the valid path, although this solve my issue. I'm attaching the modified CreatePixelShaderClass.cs for you to examinate.

file attachments


WaltRitscher wrote Jun 15, 2011 at 3:55 PM

Thanks. I'll take a look at the issue

wrote Feb 14, 2013 at 1:30 AM

wrote Aug 12, 2015 at 8:18 AM