472,090 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,090 software developers and data experts.

dynamically loading an assembly from a service (windows DRM)

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
Nov 17 '05 #1
7 2883
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
Nov 17 '05 #2
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:di*************@news.t-online.com...
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

Nov 17 '05 #3
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:u2**************@TK2MSFTNGP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:di*************@news.t-online.com...
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


Nov 17 '05 #4
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/micro...ac04b9a4d3128d

Ollie

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:u2**************@TK2MSFTNGP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:di*************@news.t-online.com...
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



Nov 17 '05 #5
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

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:%2********************@TK2MSFTNGP09.phx.gbl.. .
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/micro...ac04b9a4d3128d

Ollie

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:u2**************@TK2MSFTNGP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the
assembly isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:di*************@news.t-online.com...
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



Nov 17 '05 #6
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
Nov 17 '05 #7
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

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:di*************@news.t-online.com...
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

Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by M. Fitzgerald | last post: by
reply views Thread by leo001 | last post: by

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.