By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,335 Members | 1,385 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,335 IT Pros & Developers. It's quick & easy.

add reference programmatically

P: n/a
Hi,

I have a Windows Forms application stub (Admin.exe) that runs on a local
machine. It loads assemblies from a website programmatically using the
Assembly.LoadFrom static method.

One of the assemblies it loads is called RTC.dll, which, in the VS.NET
designer has a reference to RTCremoting.DLL, which it uses to perform
remoting of some sorts.

RTCremoting.DLL is basically

public interface IMyInt {
MyObject myMethod();
}

[Serializable]
public class MyObject {
string a, b;
}


When I use the remoting channel that is setup in RTC.dll I get a 'Cannot
find assembly RTCremoting' error message. If I change my return type for
myMethod to, say, a string there is no issue.

To resolve the problem, I had to do an 'Add Reference' on my Admin.exe to
RTCremoting.DLL in the VS.NET designer. However, I do not want to load it
this early, I want to get the RTCremoting.DLL from a remote location when
the Admin.exe loads.

Doing Assembly.LoadFrom on RTCremoting.DLL does not solve the problem. I
need to somehow reference this assembly to the executing assembly (i think)
and I have no idea how to do this. Any help would be appreciated.
Regards,

Gary Brewer



Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I have come up with an intermediate solution, I am sure this is not the best
way to do it, but kudos to Bruce Brown.

AppDomain domain=AppDomain.CurrentDomain;

domain.AssemblyResolve+=new System.ResolveEventHandler(reh);
static public Assembly reh(object o, System.ResolveEventArgs rea) {

if(rea.Name.ToUpper().IndexOf("RESOURCES")>=0) return null;

foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{

if(assembly.FullName.StartsWith(rea.Name.Split(new
char[]{','})[0])) return assembly;

}

MessageBox.Show("Couldn't find " + rea.Name);

return null;

}

Is this the only way around this?

Regards,

Gary


"Gary Brewer" <ga**@fathand.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a Windows Forms application stub (Admin.exe) that runs on a local
machine. It loads assemblies from a website programmatically using the
Assembly.LoadFrom static method.

One of the assemblies it loads is called RTC.dll, which, in the VS.NET
designer has a reference to RTCremoting.DLL, which it uses to perform
remoting of some sorts.

RTCremoting.DLL is basically

public interface IMyInt {
MyObject myMethod();
}

[Serializable]
public class MyObject {
string a, b;
}


When I use the remoting channel that is setup in RTC.dll I get a 'Cannot
find assembly RTCremoting' error message. If I change my return type for
myMethod to, say, a string there is no issue.

To resolve the problem, I had to do an 'Add Reference' on my Admin.exe to
RTCremoting.DLL in the VS.NET designer. However, I do not want to load it
this early, I want to get the RTCremoting.DLL from a remote location when
the Admin.exe loads.

Doing Assembly.LoadFrom on RTCremoting.DLL does not solve the problem. I
need to somehow reference this assembly to the executing assembly (i think) and I have no idea how to do this. Any help would be appreciated.
Regards,

Gary Brewer



Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.