473,796 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading remote assembly throws Cast Exception

I maintain a Sql Server database application whose forms are compiled
in a .dll and kept in a remote web folder. The main .exe looks to the
web folder to see if this .dll exists. If so, then it compares the
..dll with the cache copy. If the cache copy is older then it downloads
a new copy. If the .dll is not present, it throws an error.

In my main .exe, I need to early bind my "Main" form from my
FormsLibrary.dl l to get data into it. If I run my application by
loading the .dll from my local /bin folder, it works. When I run the
application by loading the .dll from the web folder, it fails, saying
there was a Cast Exception. The two .dlls are synonymous because I
copy the .dll from my local directory to the web folder.
Still, there is a version conflict.

How do I resolve this cast problem?

My code follows:

Try
Dim MyPermission As New
Permissions.Fil eIOPermission(S ecurity.Permiss ions.Permission State.Unrestric ted)

MyPermission.De mand()

'download assembly from a web server over HTTP
Dim sLocation As String
sLocation = "HTTP://gabriel/ems/FormsLibrary.dl l"

Dim formAsm As [Assembly] = [Assembly].LoadFrom(sLoca tion)

'get the form from the assembly
Dim formType As Type
formType = formAsm.GetType ("FormsLibrary. frmMain")

'create an instance of the form
Dim formObj As Object
formObj = Activator.Creat eInstance(formT ype)

'cast it to a form object to enable early binding and show
the form

**** LINE BELOW THROWS EXCEPTION WHEN REFERRING TO WEB FOLDER
..DLL
'FormsLibrary is my remote .dll

Dim frmMain As FormsLibrary.fr mMain = CType(formObj,
FormsLibrary.fr mMain)

frmMain.FormsLi braryVersion =
formAsm.GetName .Version.ToStri ng

frmMain.ShowDia log()
Catch exc As Exception
Throw exc
End Try
Jul 21 '05 #1
0 1906

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

Similar topics

1
1981
by: Kent Rollins | last post by:
I am writing a server and an MMC console app that use remoting to talk to each other. The MMC client and the server share a couple of assemblies: one has the interface that is remoted from the server and the other has some data structures that are passed across the remoted interface from the server to the client. These assemblies are not strong named and are not entered in the GAC. I could easily solve this problem by putting the DLL in...
4
1828
by: Aashish Patil | last post by:
Hi, My code is trying to load an assembly using Assembly.Load(string assemblyName); Assume that the current executing assembly is called Test.dll The following code works fine
9
4496
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
6
4503
by: Pete Davis | last post by:
I'm confused about what precisely the limitations are on loading plugins in separate app domains. In all my previous apps that supported plugins, I've loaded them into the same domain as the app, but I've just started playing around with separate AppDomains and I'm finding that I'm not having problems where I expected I would, so maybe someone can help me understand a bit better. I've read that objects instantiated in separate AppDomains...
0
298
by: Brent | last post by:
I maintain a Sql Server database application whose forms are compiled in a .dll and kept in a remote web folder. The main .exe looks to the web folder to see if this .dll exists. If so, then it compares the ..dll with the cache copy. If the cache copy is older then it downloads a new copy. If the .dll is not present, it throws an error. In my main .exe, I need to early bind my "Main" form from my FormsLibrary.dll to get data into it. If...
0
1740
by: Ratul | last post by:
Hi all! I'm writing a winforms test harness which lets me specify a subfolder from which to load a particular .net assembly dll. The idea is that there will be multiple subfolders, each having this dll. To ensure that there are no conflicts with similarly named assembly dll files, I'm am trying to load a subdirectory's dll into its own AppDomain. However when I call the AppDomain.CreateInstanceFromAndUnwrap method, it throws an...
5
3249
by: RickN | last post by:
I want to creat a new application domain called 'mydomain' and then load an assembly named 'myassembly.dll' into the domain. The assembly is in the folder "C:\Mydata\assembly", which is not the running program folder. I then want to load the 'MainClass" found in 'myassembly'. I'm having a little trouble loading because the assembly is not in the program folder. Any suggestions. Thanks, -- Rick
4
4815
by: Abhi | last post by:
Hi All, I have a web service method which works fine when called from my local machine i.e. from localhost but when I publish the web services to a remote machine it throws an invalid cast soap exception. That web service method access Active Directory to get the group names for the given user. Following is the code. DirectorySearcher dirSearcher = new DirectorySearcher();
7
2368
by: Paul Hadfield | last post by:
Hi, I'm running into one problem with trying to call "Type.GetCustomAttributes(...)" on my reflected code. Basically - I can't trap my own custom attribute - I can only catch / identify system "Custom Attributes" by type. The output below identifies that I can catch the "DefaultMemberAttribute", but I can not catch my own "DirectoryVersionAttribute". Cany anyone throw any light on this as it is driving mad Thanks in Advance, - Paul....
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.