Solved

600 Points: Using regasm with /codebase - bad?

Posted on 2004-09-08
6
672 Views
Last Modified: 2012-05-05
Hey all,

This will be an additional 500 points on a complete satisfactory answer (I have an open question with similar problem for 500 points).

I've been messing around with a problem found here (not really necessary to read): http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21122681.html

After an extremely long time I finally managed to get it to work. However, in order to make it work, I have to register my project dll with regasm.exe using the /codebase parameter. Now I read this post of someone (scroll down for the last post): http://dotnetjunkies.com/Newsgroups/microsoft.public.dotnet.distributed_apps/2004/2/27/40357.aspx

that you should *never* register with regasm using /codebase. Well, since I know very little about these things, and I've been working on this for a week now and know no other way than to make this work, I'm a little bit like 'uhu, whatever'.

Can someone explain me what the chances are of errors when doing so? Is it really that bad? And, if it is, is there a way to fix this? (will need to read my 500 point question for this). I will only accept very good answers for 600 points, either by providing a solution to my other post, or when the answer is complete, detailed, and understandable what the problem is with /codebase or why I can use it anyway ;)

Thanks,

Razzie
0
Comment
Question by:Razzie_
  • 3
  • 2
6 Comments
 
LVL 5

Assisted Solution

by:tomasX2
tomasX2 earned 20 total points
ID: 12016576
"Using /codebase to register an assembly without a strong name should only be done for testing purposes. Ordinarilly, private assembles should reside in the same directory or a subdirectory of an application, but /codebase enables you to circumvent this rule.  If multiple applications have assemblies without strong names that contain types with the same names, subtle incorrect behaviour can occur by the wrong types getting loaded"   Taken from .Net and Com The complete interoperablitity guide
0
 
LVL 8

Author Comment

by:Razzie_
ID: 12016683
yeah but "If multiple applications have assemblies without strong names that contain types with the same names, subtle incorrect behaviour can occur by the wrong types getting loaded"

now THAT's what I'm wondering. What does it mean *exactly*? 2 Object of the same type with the same name? What are the chances of this? Can this happen every time, or is the chance like 1 in 10 million? Does giving your class a ridiculous circumvent this?
0
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 80 total points
ID: 12017083
In DotNET there are Namespaces, which is an attempt to keep components straight.  Now lets say that a company (My Company) decides that they will use a non-standard namespace mc.???? instead of their registered domain and another company (Marie's Company) has a regestered domain (mc) and they are using that as their namespace, so again mc.????.  Now lets also say that both My Comapany and Marie's Company develop software utilities and both have developed something like mc.utils.httpUtils.  You then get applications or tools from both My Company and Marie's Company and a dll that you wrote tries to use mc.utils.httpUtils.  Which class will get loaded, My Company's or Marie's Company's?  The answer is that you do not know and therefore your code may exhibit odd behavior because the wrong class is being used!  This is the risk that you run using /codebase.  If you put the appropriate dll in the directory of the code using the dll (assembly)  then you will also know because it will DotNET will load that assembly.

To get your code to work without using /codebase on the regasm you would simply put all of the dll's that your code needs in the same directory.  There are both advantages and disadvantages using this approach.  The advantage is that you can reduce your chances of ending up in dll hell or having unexpected behavior.  The disadvantage is that the dll's will exist in multiple areas.

Another issue that can arise is where you use the /codebase to register your code  and then you update one of the base dll's and BAM all of a sudden you code that used to work does not, why?  Well when you changed the dll there was no gaurentee that the appropriate intreface still existed for your code and since your code is mapped to the dll you change and is not using one in it's own directory your code no longer works.

Hope this helps.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Author Comment

by:Razzie_
ID: 12017242
NipNFriar_Tuck,

It sure helps. But still a few questions.

As I understand it, if you use a 'special' namespace of which you are let's say 99,99% sure nobody else will use it, you are in principal safe to use the /codebase parameter?

'To get your code to work without using /codebase on the regasm you would simply put all of the dll's that your code needs in the same directory' - they are in the same directory, I uploaded my whole output directory to another directory on the deployement machine. I did the regasm.exe without /codebase, and it said something like 'Assembly registered succesfully'. However, after doing a few tests on the deployement machine, I was absolutely sure that it didn't really do anything, because I saw no difference after registering. Are you sure it should work? If you are, I might try to clean up the register and start from scratch.

Thanks,

Razzie
0
 
LVL 7

Expert Comment

by:NipNFriar_Tuck
ID: 12017344
I would say if the risks are acceptable then using /codebase may be a solution, however I would make sure to document it since a year down the road when this conversation is long forgotten and the applications starts acting up you do not want to be in the dark.

I am also 99% sure that putting the dlls in the same directory as the code should work.  One thing that may be an issue is if you did not use the copy local parameter on all referenced assemblies to copy all referenced assemblies to the output directory, since then you would be missing a dll.
0
 
LVL 8

Author Comment

by:Razzie_
ID: 12026665
Well I experienced myself that it can cause problems when hooking it to my SMTP server twice, unfortunately I really can't register without the /codebase. But since I simply changed my namespace into something else, the problems were gone, I just need to document it right like you said Nip, and it won't be too bad. The chances of it interfering with completely different applications are - as I understand it - very very slim that way.

This will work for me since I have no other problems now anymore.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now