Outprocess library in .NET

O

Ostap Radkovskiy

Hi!

I'm using MSMQ triggers to launch COM object written in C#. Unfortunately, there is a need to have some .config file attached to my COM, so it could read necessary settings within. As far as I understand my class library (written in c# and registered as COM object) is an inprocess COM running inside the caller process and have no possibility to find it's config file (moreover, .NET studio does not allow attaching ..config files to class libraries). How can I handle this?

Thanks for the suggestions,
Ostap Radkovskiy,
SoftServe, Inc
 
D

David Browne

I'm using MSMQ triggers to launch COM object written in C#. Unfortunately,
there is a need to >have some .config file attached to my COM, so it could
read necessary settings within. As far as >I understand my class library
(written in c# and registered as COM object) is an inprocess COM >running
inside the caller process and have no possibility to find it's config file
(moreover, >.NET studio does not allow attaching .config files to class
libraries). How can I handle this?

Your C# dll is an Assembly.
If your assembly is not shadow copied, and it is not in the GAC, you can put
your config file in the same directory as your dll and get that location
with

string path
=System.IO.Directory.GetParent(System.Reflection.Assembly.GetExecutingAssemb
ly().Location).FullName;


You may need to register your assembly with the /codebase option for it to
be found by COM clients outside the GAC.

regasm MyLibrary.dll /tlb:MyLibrary.tlb /codebase


David
 
O

Ostap Radkovskiy

Thanks David,

that's it. First I was worried about the special situation I have: I need to
instantiate some classes inside my COM and call their methods. Fortunately,
these methods do not use System.Configuration (they are incapsulated for me
so if they would use, it would be no use of reading .config xml manually).
So now I'll just read xml by the path your code returns, and feed some
parameters.

Thanks, the answer was really helpful!

Ostap Radkovskiy,
SoftServe, Inc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top