473,490 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2580
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1921
by: karunakar | last post by:
Hi All I am not able to read the class name I want read the particular class name string path = System.Configuration.ConfigurationSettings.AppSettings; string className = path + ".User";...
3
12155
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
3
2062
by: Karl Hungus | last post by:
A cs file I compiled into an assembly dll is in my bin directory. In the cs file I have a using statement for System.Xml I compiled it using this command: csc /out:XmlContent.dll /t:library...
1
7102
by: Scott Hamlin | last post by:
I am receiving an error while trying to use Crystal Reports with .NET, which I have pasted below. The main problem is this message: File or assembly name CrystalDecisions.CrystalReports.Engine,...
4
4439
by: =?Utf-8?B?SmFu?= | last post by:
I have a .NET 2.0 application divided in two assemblies; the exe and a dll. The application generates a plugin-dll which is then loaded in a separate AppDomain (along with a second instance of my...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.