473,499 Members | 1,862 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.dll 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.FileIOPermission(Security.Permissions. PermissionState.Unrestricted)

MyPermission.Demand()

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

Dim formAsm As [Assembly] = [Assembly].LoadFrom(sLocation)

'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.CreateInstance(formType)

'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.frmMain = CType(formObj,
FormsLibrary.frmMain)

frmMain.FormsLibraryVersion =
formAsm.GetName.Version.ToString

frmMain.ShowDialog()
Catch exc As Exception
Throw exc
End Try
Jul 21 '05 #1
0 1872

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

Similar topics

1
1954
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...
4
1812
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
4463
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...
6
4482
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,...
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...
0
1706
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...
5
3225
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...
4
4796
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...
7
2345
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...
0
7134
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
7012
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
7180
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,...
0
7225
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
7392
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...
0
5479
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
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
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...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.