471,078 Members | 843 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Assembly not found

I'm using reflection to dynamically load an assembly and
even though I'm sure the assembly is present, I keep
getting an error telling me the "assembly or one of its
references can't be found".

I do in fact have a reference to the assembly in question
in the project and I even tried declaring it with "using"
at the top of the class file.

Here's the method that fails:

public IDataAdapter CreateAdapter(string query,
IDbConnection connection)
{
object[] args = {query, connection};

//load the assembly and class
Assembly asmb = Assembly.Load("FirebirdSql.Data.Firebird");

Type type = asmb.GetType("FbDataAdapter");

IDataAdapter da = Activator.CreateInstance(type, args)
as IDataAdapter;

return da;
}

The "FirebirdSql.Data.Firebird" assembly can't be found,
even though it's there. It's in my GAC and available as
I'm using it elsewhere w/o a problem.

What could be the problem?

Thanks!

-v

Nov 16 '05 #1
4 2471
V. Jenks wrote:
I'm using reflection to dynamically load an assembly and
even though I'm sure the assembly is present, I keep
getting an error telling me the "assembly or one of its
references can't be found".

I do in fact have a reference to the assembly in question
in the project and I even tried declaring it with "using"
at the top of the class file.

Here's the method that fails:

public IDataAdapter CreateAdapter(string query,
IDbConnection connection)
{
object[] args = {query, connection};

//load the assembly and class
Assembly asmb = Assembly.Load("FirebirdSql.Data.Firebird");

Type type = asmb.GetType("FbDataAdapter");

IDataAdapter da = Activator.CreateInstance(type, args)
as IDataAdapter;

return da;
}

The "FirebirdSql.Data.Firebird" assembly can't be found,
even though it's there. It's in my GAC and available as
I'm using it elsewhere w/o a problem.


Start the tool fuslogvw.exe and examine the log fusion has written when
it failed to load the assembly. As the firebird provider is signed,
perhaps you should specify it's full name. Either way, the log will
explain what paths it has checked and for which file.

Fuslogvw.exe is part of the .net sdk and if you have vs.net installed
on your system you have it installed as well.

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog : http://weblogs.asp.net/FBouma
Microsoft MVP (C#)
Nov 16 '05 #2
I tried this, there is nothing listed in the log at all.
Also, if I choose anything but "Default" from the radio
button list on the right, I get an error that says:

"Error: Unable to open cache file!"

I am using the full name of the Firebird driver. If I
switch to SQL Server, it also fails.

But...in the very same class, this method runs and works
just fine, which seems very strange to me:

public IDataHelper Create()
{
//get configuration values for the assembly and class
string assemblyName = Config.DataHelperFactoryAssembly;
string className = Config.DataHelperFactoryClass;

//load the assembly and class
IDataHelper dh =
(IDataHelper)Assembly.Load(assemblyName).CreateIns tance(className);

return dh;
}

Config.DataHelperFactoryAssembly and
Config.DataHelperFactoryClass call an assembly & class I
that I wrote myself.....and it works.

What's the problem with calling external assemblies?

I would use LoadFrom but I need it to be more flexible than
that...I can't very well make it portable if I have to
worry about paths breaking to my assemblies.

Thanks!
-----Original Message-----
V. Jenks wrote:
I'm using reflection to dynamically load an assembly and
even though I'm sure the assembly is present, I keep
getting an error telling me the "assembly or one of its
references can't be found".

I do in fact have a reference to the assembly in question
in the project and I even tried declaring it with "using"
at the top of the class file.

Here's the method that fails:

public IDataAdapter CreateAdapter(string query,
IDbConnection connection)
{
object[] args = {query, connection};

//load the assembly and class
Assembly asmb = Assembly.Load("FirebirdSql.Data.Firebird");
Type type = asmb.GetType("FbDataAdapter");

IDataAdapter da = Activator.CreateInstance(type, args)
as IDataAdapter;

return da;
}

The "FirebirdSql.Data.Firebird" assembly can't be found,
even though it's there. It's in my GAC and available as
I'm using it elsewhere w/o a problem.
Start the tool fuslogvw.exe and examine the log fusion

has written whenit failed to load the assembly. As the firebird provider is signed,perhaps you should specify it's full name. Either way, the log willexplain what paths it has checked and for which file.

Fuslogvw.exe is part of the .net sdk and if you have vs.net installedon your system you have it installed as well.

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.comMy .NET Blog : http://weblogs.asp.net/FBouma
Microsoft MVP (C#)
.

Nov 16 '05 #3
You have not described where the assemblies are located in relation to the
executable. Is the assembly in the GAC, in a local directory, etc? Does the
other assembly have dependencies to other assemblies?

Also, using the form Assembly.Load usually requires that you specify the
assembly's full 4 part name (name, version, culture, public key token).

There's nothing intrinsically inflexible about using LoadFrom with paths,
but there are side effects.

<an*******@discussions.microsoft.com> wrote in message
news:12****************************@phx.gbl...
I tried this, there is nothing listed in the log at all.
Also, if I choose anything but "Default" from the radio
button list on the right, I get an error that says:

"Error: Unable to open cache file!"

I am using the full name of the Firebird driver. If I
switch to SQL Server, it also fails.

But...in the very same class, this method runs and works
just fine, which seems very strange to me:

public IDataHelper Create()
{
//get configuration values for the assembly and class
string assemblyName = Config.DataHelperFactoryAssembly;
string className = Config.DataHelperFactoryClass;

//load the assembly and class
IDataHelper dh =
(IDataHelper)Assembly.Load(assemblyName).CreateIns tance(className);

return dh;
}

Config.DataHelperFactoryAssembly and
Config.DataHelperFactoryClass call an assembly & class I
that I wrote myself.....and it works.

What's the problem with calling external assemblies?

I would use LoadFrom but I need it to be more flexible than
that...I can't very well make it portable if I have to
worry about paths breaking to my assemblies.

Thanks!
-----Original Message-----
V. Jenks wrote:
I'm using reflection to dynamically load an assembly and
even though I'm sure the assembly is present, I keep
getting an error telling me the "assembly or one of its
references can't be found".

I do in fact have a reference to the assembly in question
in the project and I even tried declaring it with "using"
at the top of the class file.

Here's the method that fails:

public IDataAdapter CreateAdapter(string query,
IDbConnection connection)
{
object[] args = {query, connection};

//load the assembly and class
Assembly asmb = Assembly.Load("FirebirdSql.Data.Firebird");
Type type = asmb.GetType("FbDataAdapter");

IDataAdapter da = Activator.CreateInstance(type, args)
as IDataAdapter;

return da;
}

The "FirebirdSql.Data.Firebird" assembly can't be found,
even though it's there. It's in my GAC and available as
I'm using it elsewhere w/o a problem.


Start the tool fuslogvw.exe and examine the log fusion

has written when
it failed to load the assembly. As the firebird provider

is signed,
perhaps you should specify it's full name. Either way, the

log will
explain what paths it has checked and for which file.

Fuslogvw.exe is part of the .net sdk and if you have

vs.net installed
on your system you have it installed as well.

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET:

http://www.llblgen.com
My .NET Blog : http://weblogs.asp.net/FBouma
Microsoft MVP (C#)
.

Nov 16 '05 #4
If the FirebirdSql.Data.Firebird assembly is located somewhere other than the application directory or a directory under the app directory called FirebirdSql.Data.Firebird then it will not be found by default. If it is in the GAC of at a codebase hint you will have to fully qualofy the assembly name with the version, culture and public key token. If its in some other directory under the app directory you will have to add a <probing> element into your app config file to extend the paths searched under the app directory.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<11****************************@phx.gbl>

I'm using reflection to dynamically load an assembly and
even though I'm sure the assembly is present, I keep
getting an error telling me the "assembly or one of its
references can't be found".

I do in fact have a reference to the assembly in question
in the project and I even tried declaring it with "using"
at the top of the class file.

Here's the method that fails:

public IDataAdapter CreateAdapter(string query,
IDbConnection connection)
{
object[] args = {query, connection};

//load the assembly and class
Assembly asmb = Assembly.Load("FirebirdSql.Data.Firebird");
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Karl Hungus | last post: by
1 post views Thread by Scott Hamlin | last post: by
4 posts views Thread by =?Utf-8?B?SmFu?= | 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.