473,385 Members | 2,210 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,385 software developers and data experts.

add reference programmatically

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
1 11233
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick Douglas | last post by:
Hello, I'd like to programmatically reference the Excel Object Library from an Access form using VB. I am using this code: Application.VBE.vbprojects("VBAProject").References.AddFromFile...
6
by: frankplank | last post by:
Hi *, I'm wondering if it is possible to create a C# object, and reference it *explicitly* in an excel document. I imagine this will be more possible if I programmatically populate the excel...
6
by: Adam Right | last post by:
Hi, I am developing a project which uses "Microsoft Word Interop". There may be a case in which the end-user may not have Microsoft Office or Office Interops. So i do not want to add a com...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
3
by: Kiran | last post by:
Hi, If I create a Virtual directory with application name programmatically it will not show up in the available web services while adding web reference(Dynamic discovery fails). Where as if I...
3
by: TC | last post by:
Hello All, I have winforms app that accesses a webservice and the WSDL is referenced dynamically. I was wondering 2 things: First, if one parses the .config file and changes the URL...
1
by: Michel Couche | last post by:
Hello, I am starting the development of a newsletter The use of the class MailMessage of System.Net.Mail is quite straightforward for usual contact forms but my question here is "How can I...
1
by: Nathan Sokalski | last post by:
I have a UserControl that I declare programmatically as follows: Dim userctrl as New rightside_portal() The codebehind file for this UserControl looks like the following: Partial Public...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.