Assembly.LoadFrom(file) problem

  • Thread starter Thread starter Saso Zagoranski
  • Start date Start date
S

Saso Zagoranski

Hi!

I'm trying to load an assembly by using:
Assembly assembly = Assembly.LoadFrom(path + line);
where
string path =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
ualifiedName)+ "\\";

I've used the messagebox to see wheter path+line is correct and it is!
I manually copy the assembly into the same directory as the application. Any
ideas?
Why does this exception occur?

thanks,
saso
 
What exception are you getting? And can you post the resulting string from
the concatenation of "path + line"?
 
the path is:
\Program files\HotSpotsMobile\TestModule.dll, which is exactly where the
module is...

I get an IOException... As I've seen in some other post It could be a
FileLoadException
although I couldn't catch it because I can't find it in the framework...
But it still is an IOexception so the application can't read the file...
could it be security related?

Tim Wilson said:
What exception are you getting? And can you post the resulting string from
the concatenation of "path + line"?

--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}
Saso Zagoranski said:
Hi!

I'm trying to load an assembly by using:
Assembly assembly = Assembly.LoadFrom(path + line);
where
string path =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
ualifiedName)+ "\\";

I've used the messagebox to see wheter path+line is correct and it is!
I manually copy the assembly into the same directory as the application. Any
ideas?
Why does this exception occur?

thanks,
saso
 
I have not had a problem dynamically loading an assembly. You might want to
try a few things:
(1) If you do not already have SP2 you can get it here:
http://tinyurl.com/2uj3u
(2) Create a simple class library, compile it into an assembly, and send it
to a known location on the device.
(3) Create a very basic win forms application that will just load the
assembly (with a hard coded path) like this:
using System.Reflection;
Assembly a = Assembly.LoadFrom(@"\Program Files\MyTestApp\ClassLib.dll");

Does this seem to work?

--
Tim Wilson
..Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}

Saso Zagoranski said:
the path is:
\Program files\HotSpotsMobile\TestModule.dll, which is exactly where the
module is...

I get an IOException... As I've seen in some other post It could be a
FileLoadException
although I couldn't catch it because I can't find it in the framework...
But it still is an IOexception so the application can't read the file...
could it be security related?

Tim Wilson said:
What exception are you getting? And can you post the resulting string from
the concatenation of "path + line"?
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
application.
Any
 
I'm having trouble getting SP2 to work on the emulator... I install
it manually but then I can't even debug... So I'm going to try and test it
on an actual pocketpc device and will let you know whether or not it
worked...
I've also tried hardcoding the path and the result is the same
Although I've heard that It's not actually that the Assembly.LoadFrom(file)
couldn't
find the file but it's in fact security related.

Tim Wilson said:
I have not had a problem dynamically loading an assembly. You might want to
try a few things:
(1) If you do not already have SP2 you can get it here:
http://tinyurl.com/2uj3u
(2) Create a simple class library, compile it into an assembly, and send it
to a known location on the device.
(3) Create a very basic win forms application that will just load the
assembly (with a hard coded path) like this:
using System.Reflection;
Assembly a = Assembly.LoadFrom(@"\Program Files\MyTestApp\ClassLib.dll");

Does this seem to work?

--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}

Saso Zagoranski said:
the path is:
\Program files\HotSpotsMobile\TestModule.dll, which is exactly where the
module is...

I get an IOException... As I've seen in some other post It could be a
FileLoadException
although I couldn't catch it because I can't find it in the framework...
But it still is an IOexception so the application can't read the file...
could it be security related?
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
 
I have tested it with SP2 installed on my PocketPc and it works!
Just one more thing... I can't deploy my project to the device (I have to
copy it manualy)
because VS.NET (2003) says:
Files in the package 'netcf.core.ppc3.arm.cab' are more recent on the device
than on the development computer. Consider upgrading to the latest version.

How can I update the VS.net CF?

Thanks for the help!
saso
Tim Wilson said:
I have not had a problem dynamically loading an assembly. You might want to
try a few things:
(1) If you do not already have SP2 you can get it here:
http://tinyurl.com/2uj3u
(2) Create a simple class library, compile it into an assembly, and send it
to a known location on the device.
(3) Create a very basic win forms application that will just load the
assembly (with a hard coded path) like this:
using System.Reflection;
Assembly a = Assembly.LoadFrom(@"\Program Files\MyTestApp\ClassLib.dll");

Does this seem to work?

--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}

Saso Zagoranski said:
the path is:
\Program files\HotSpotsMobile\TestModule.dll, which is exactly where the
module is...

I get an IOException... As I've seen in some other post It could be a
FileLoadException
although I couldn't catch it because I can't find it in the framework...
But it still is an IOexception so the application can't read the file...
could it be security related?
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
 
The message about the assemblies on the device being more recent is is a
normal message to get once you have upgraded the device to SP2. But your
application should still deploy fine. It's just that VS.Net won't try to
deploy/install the CF (again). You should be able to update the CAB that
VS.Net deploys by following the link below. Although MS does not officially
support updating VS.Net 2003, in other words, there has not been a service
pack for VS.Net 2003 that addresses this issue.
http://makeashorterlink.com/?S19F25857

--
Tim Wilson
..Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}

Saso Zagoranski said:
I have tested it with SP2 installed on my PocketPc and it works!
Just one more thing... I can't deploy my project to the device (I have to
copy it manualy)
because VS.NET (2003) says:
Files in the package 'netcf.core.ppc3.arm.cab' are more recent on the device
than on the development computer. Consider upgrading to the latest version.

How can I update the VS.net CF?

Thanks for the help!
saso
Tim Wilson said:
I have not had a problem dynamically loading an assembly. You might want to
try a few things:
(1) If you do not already have SP2 you can get it here:
http://tinyurl.com/2uj3u
(2) Create a simple class library, compile it into an assembly, and send it
to a known location on the device.
(3) Create a very basic win forms application that will just load the
assembly (with a hard coded path) like this:
using System.Reflection;
Assembly a = Assembly.LoadFrom(@"\Program Files\MyTestApp\ClassLib.dll");

Does this seem to work?

--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}

string
from
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQ
 
Back
Top