473,320 Members | 1,535 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,320 software developers and data experts.

c# run-time load of assembly problem

Hi all.

Here is description of my run-time assembly loading problem:

I would like to have winService hosting .Net remoting objects.
But, it should work in sort of pluginable way, so during starting of winService it would look into certain folder configured with App.config and dynamically load assemblies from deployed dll-s. Registering of remote objects would be done in some AddonXXX: IAddonXXX class that is defined in each dll, and some mutual interface IAddonXXX would be used to identify those addon classes after assembly is loaded in run-time.

This all sound ok, but now I have encounter following problem.

Naturally, my plugin dll references some other dlls, and after loading of assembly when addonAssembly.GetExportedTypes is executed I keep getting this error:

"Could not load file or assembly 'DALXXXModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

I tried pretty much all I though it could make a difference.

System.Reflection.Assembly.Load
AppDomain.CurrentDomain.Load

even I deployed all referenced dlls and load them in order that first are loaded referenced dlls and plugin dll at the end, but error remains same.

So, my question is:

What is correct way to load dll at runtime? And I would prefer if dll should not be stored in GAC.

So, somehow I suppose that this should be common thing to do and there is probably right way to do this... Can anybody help me? Tnx.
Mar 27 '08 #1
2 2873
here is also code:
...
System.Reflection.Assembly addonAssembly;
XmlDocument xmlConfig;

foreach (string fileName in Directory.GetFiles(FolderName, "*PluginConfiguration.xml"))
{
xmlConfig = new XmlDocument();
xmlConfig.Load(fileName);
XmlNodeList assemblyIdentityNodes = xmlConfig.GetElementsByTagName("assemblyIdentity") ;

foreach (XmlNode assemblyIdentityNode in assemblyIdentityNodes)
{
string dllName = FolderName + "\\" + assemblyIdentityNode.Attributes["name"].Value;

byte[] rawAssembly = IOUtils.LoadFile(dllName);
byte[] rawSymbolStore = IOUtils.LoadFile(dllName.Substring(0, dllName.Length - 3) + "pdb");

addonAssembly = AppDomain.CurrentDomain.Load(rawAssembly);//, rawSymbolStore);

foreach (System.Type exportedType in addonAssembly.GetExportedTypes())
{
IRemotingBIZModuleAddon addonInstance;
try
{
addonInstance = (IRemotingBIZModuleAddon)addonAssembly.CreateInsta nce(exportedType.FullName, true);
}
catch (Exception ex)
{
addonInstance = null;
}

if (addonInstance != null)
{
addonInstance.Install(logWriter, this);
}
}
}
}
...


error is raised with addonAssembly.GetExportedTypes()
Mar 27 '08 #2
Ok, I found solution.

following config should be added into App.config of winService project

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="AddonRemoteObjectsFolder" />
</assemblyBinding>
</runtime>

all "private paths" that would be used to hold dll-s must be registered through probing element.

So, this thread can be closed now.
Mar 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
5
by: Patrice FRITSCH | last post by:
I'm trying to run a batch file from an asp page using WScript.Shell object. Dim oWSH set oWSH= Server.CreateObject("WScript.Shell") call oWSH.Run("cmd.exe /c " & szCmd , 0, true) szCmd...
2
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public:...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
2
by: a16908 | last post by:
Please help me, I need a help. I want to know how to make my PC run fast. I did every thing like :1. Run Disk clean-up. Then delete unused files. (start>program>accessories>sys... tools> disk...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.