Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2005

Tip: Looking for answers? Try searching our database.

dynamically loading an assembly from a service (windows DRM)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ollie Riches - 06 Oct 2005 18:13 GMT
I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.dll' which is a PIA to the windows media player DRM
components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load from
a windows service an exception is thrown with the following message:

"File or assembly name Interop.WMEncoderLib, or one of its dependencies, was
not found."

Now I am guessing this is because the windows service runs under the
location of 'windows root\system32' not where there service execute is
installed. The assemblies I am loading at runtime resides in a sub directory
(with all the dll's referenced by the assembly) and are designed as a
plugable architecture that returns an interface to the caller.

public static IIngestor CreateInstance(string assemblyName, string
classType, object[] args)
{
   Assembly loadedAssembly = Assembly.LoadFrom(assemblyName);
   IIngestor ingestor = (IIngestor)loadedAssembly.CreateInstance(classType,
true, BindingFlags.Default, null, args, null, null);
   if(ingestor == null)
       throw new System.ArgumentException("Failed to create ingestor
invalid assembly or class name, assembly = '" + assemblyName + "', class
name ='" + classType + "'.");
   return ingestor;
}

Can anyone help me out here

Cheers

Ollie Riches
Robert Jordan - 06 Oct 2005 18:17 GMT
Ollie,

> I am trying to dynamically load an assembly that has a reference to
> 'Interop.WMEncoderLib.dll' which is a PIA to the windows media player DRM
> components. When I run the code from a console application it works
> perfectly fine, but when the assembly containing the reference is load from
> a windows service an exception is thrown with the following message:

If that assembly is a PIA, why don't you install it into the GAC?

Rob
Ollie Riches - 06 Oct 2005 19:36 GMT
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

> Ollie,
>
[quoted text clipped - 7 lines]
>
> Rob
Ollie Riches - 06 Oct 2005 19:56 GMT
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx

Ollie

> Good Idea :) and probably will work, but doesn't explain why the assembly
> isn't loading
[quoted text clipped - 13 lines]
>>
>> Rob
Ollie Riches - 06 Oct 2005 20:03 GMT
I think I will try using the AssemblyResolve event on the current appDomain
to see if that can help resolve the location of the interop assembly.

found an interresting google at:

http://groups.google.com/group/microsoft.public.dotnet.framework/browse_frm/thre
ad/59fc2f276501e0e0/2bac04b9a4d3128d?lnk=st&q=Interop+assembly.load+failed+depen
dencies&rnum=1&hl=en#2bac04b9a4d3128d


Ollie

> found this and will have a look at it tomorrow:
>
[quoted text clipped - 19 lines]
>>>
>>> Rob
Ollie Riches - 07 Oct 2005 13:47 GMT
Still failing, but if I place the assemblies in the same directory as the
service binary then it loads the assemblies perfrectly fine.

I have tried using the AssemblyResolve event and the AppendPrivatePath on
the current app domain but still it fails

Ollie

>I think I will try using the AssemblyResolve event on the current appDomain
>to see if that can help resolve the location of the interop assembly.
[quoted text clipped - 28 lines]
>>>>
>>>> Rob
Robert Jordan - 07 Oct 2005 14:00 GMT
Hi Ollie,

> Still failing, but if I place the assemblies in the same directory as the
> service binary then it loads the assemblies perfrectly fine.
>
> I have tried using the AssemblyResolve event and the AppendPrivatePath on
> the current app domain but still it fails

Are you still using Assembly.LoadFrom? This method is
actually loading the assembly either from the full path
you specified or relatively to the app's current directory.

Try Assembly.Load with the strong name of the PIA.

For the first, the strong name can be as simple as
"Interop.WMEncoderLib", but take a look at "gacutil -l"
output for the full name.

Rob
Ollie Riches - 07 Oct 2005 14:52 GMT
Cheers for the help Robert, I have been using LoadFrom with fully qualified
path with no success.

I will have to resort to either putting the plugin dll's in the same
directory as the windows service or as you suggested registering the PIA's
in the GAC. But for now i have it working and will address this problem
again next week.

Cheers for the help

Ollie

> Hi Ollie,
>
[quoted text clipped - 15 lines]
>
> Rob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.