LoadFrom / Load to load an assembly created in .Net 1.1

G

Guest

Hi,

In our project we use the following lines to compile some #c code (c# is
some runtime generated code):

CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();
cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
cp.GenerateExecutable = false;
cp.GenerateInMemory = false;
cp.OutputAssembly = target; //target is the full name of the dll created
cp.TreatWarningsAsErrors = false;
cp.WarningLevel = 0;

CompilerResults ces = provider.CompileAssemblyFromSource(cp, mCS); //mCS is
the code to be compiled

So the code is compiled and a dll is created.

With the following code the newly created dll is loaded:
Assembly As = Assembly.LoadFrom(@"C:\yyy\xxx.dll"); //hard coded path to dll
Object ScriptClass =
As.CreateInstance("FarmLine.ControlLogic.F2KScriptEngine." + "xxx.dll");

This worked fine in .Net 1.1.

Now we want to use the same code in .Net 2.0 to load a dll formely created
with .Net 1.1, but 'Ass.CreateInstance' returns null. I've read on the
internet that you better use Assembly.Load() but this does not work either.

Does anyone knows a solution that will solve this problem? I can send the
dll and two lines of code to reproduce the problem,

kind regards,
Koert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top