473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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

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.GetExecutingA ssembly().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.F2KScript Engine." + "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
Mar 15 '07 #1
1 1191
Solved

"Koert" wrote:
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.GetExecutingA ssembly().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.F2KScript Engine." + "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
Mar 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: surya | last post by:
Hi, I use the Assembly.LoadFrom call in my code to load assemblies dynamically. This call currently loads both signed and unsigned assemblies. It now needs to be changed to load only signed...
0
by: surya | last post by:
Hi, I am using Assembly.LoadFrom within a web service to load assemblies from a web site. This web site is in the same machine where I am running the web service. The...
2
by: Greg Bacchus | last post by:
Hi, Does anyone know how to get an offline reference to an assembly that has been downloaded using Assembly.LoadFrom. E.g. Application downloads the assembly while it in online... next time it...
2
by: daveland | last post by:
The following fragment of code exhibits some anomolous behavior: public IDbConnection GetConnection(string cnstr) { 1 IDbConnection cn = null; 2 Assembly a = Assembly.Load("System.Data");...
0
by: Oenone | last post by:
I have created a number of "plug-in" DLLs for my ASP.NET application which are dynamically loaded at run-time. This is done by locating the DLL file on disk and loading it using the...
11
by: Michael Maes | last post by:
Hello, I want to be able to load an assembly by selecting a dll from an OpenFileDialog. This seems to work, exept when that assembly references "3rd-Party dll's". Just this simple line: Dim...
1
by: Gujju | last post by:
Hi all, Whats the difference betwn Assembly.Load(FileName) and Assembly.LoadFrom(FileName.dll) ? Cheers C
2
by: Peted | last post by:
can anyone help me with the following bellow is a routine i use that works, that will load an assembly from a dll class from the HDD, and instantiate a form to be used to control a device. ...
3
by: dbhurt15 | last post by:
Let me say first that I'm brand new to .NET I'm having a small issue. I'm working on a large project. My part is using a .dll located in another directory. I'm having problems referencing to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.