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

Late Binding: Sharing Source Files <-> Casting Problem

Dear all,

here is a simple problem that I cannot overcome:
I'm trying to write a client/server application in Visual Basic .net. The
server is an executable (.exe) project, the clients are class library (.dll)
projects. The server loads the clients from their DLL-files at runtime using
reflection tools, such as:

ClientAssembly =
System.Reflection.Assembly.LoadFrom(Client_To_Load _File_Name)

In the next step, the server wants to get access to a class that is
integrated in every client. To integrate it, the class is shared by all
clients and the server on a source file basis, i.e. all clients and the
server link (not copy) to the source file. Furthermore, the root namespace
of all projects is set to "". If we call the common class "MyClass", the
server is able to gain access to a client's imported copy by calling

dim x as Object
x = ClientAssembly.CreateInstance("MyClass")

So far, this all works fine. Now, the server wants to finally cast the
resulting object to a "MyClass" object, as it knows this class by source
code:

dim y as MyClass
y = CType(x, MyClass)

The latter function, however, failes during runtime with a message that
there is no appropriate conversion between the types "MyClass" and
"MyClass".

Obviously (...I think...), the problem is related to the fact, that at
runtime both server and client have integrated their copy of the MyClass
source code into their assembly in binary format. Consequently, the .net
framework sees both versions as different types and does not find an
appropriate cast.

To get over the problem, I found only to unsatisfying solutions:
1. Compile the class definitions in another Class Library. Link server and
clients to the assembly of this class library instead of the source code. In
this case, all players access the same _binary_ representation of the class.
The problem with this solution is that I have to recompile this new, central
class library with every change.
2. I do not use the cast mechanisms but only work with objects of type
"Object". This works but source code appears to be less clear.

Now the question: Is there any method to share a file of source code that
contains structure/class definitions and is it somehow possible for an
assembly to access structure/class objects of other assemblies at runtime if
there is no reference given to these assemblies at compile time?

Thanks,

John
Nov 20 '05 #1
0 1262

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

Similar topics

9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
1
by: Robin Tucker | last post by:
I've run foul of this bug advisory from Microsoft: http://support.microsoft.com/default.aspx?scid=kb;en-us;292744 My preferred solution of the two listed is to use late binding. I have Option...
0
by: Rocio | last post by:
Here I go again. Some time ago I wrote a VB.NET web service application that called a COM object written in VB6 using late binding. It was the only way I could call this object (see my posting in...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
4
by: Heinz | last post by:
Hi all, I use VB.net 2003 and want to export data to Excel. Target PCs still have Office 2000 so I could not use Microsofts PIAs. Instead I use the included Excel 10 COM DLL from Microsoft....
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
21
by: ManningFan | last post by:
I need to use late binding in a project because it's company standard to not include references which aren't MS defaults, so I can't add the scripting runtime. I need to be able to search...
2
by: GS | last post by:
I have installed the ms PIA for ofc XP, and followed the article http://support.microsoft.com/kb/247412/ trying to paste into a worksheet However I got late binding not allowed errors .......
3
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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
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,...

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.