Outprocess library in .NET

  • Thread starter Thread starter Ostap Radkovskiy
  • Start date Start date
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
 
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
 
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
 
Back
Top