473,503 Members | 12,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return Class instance from dynamically loaded DLL?

I use dynamically loaded dll's a lot in my programs. The one thing i cannot
figure out how do is too to sucessfully pass the address of a class instance
created within the dynamically loaded dll. I step thru the code and confirm
that the class is correctly created in the dll, but as soon as it steps out
of the dll i loose the address. For example:

hLib = LoadLibrary("RasterIO.dll");

ImageIOClass *ImageIO = (ImageIOClass
*)GetProcAddress((HINSTANCE)hLib, "_GetImageIOClass");
if (ImageIO != NULL)
{
TRasterIO *IO;
ImageIO(IO, ...); // instance created with new in dll.
if (IO)
{
// do something with IO
....
}
else
{
return;
}

delete IO;
}
UnloadPackage(hLib);

That is the basic idea of what i am trying to do. If i statically link the
dll i can get an instance of the class no problem. I suppose this is all
something to do with the way dlls handle and share memory - something i
obviously do not understand!

Peter
Jul 19 '05 #1
0 1679

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14887
by: MKoleoso | last post by:
Problem: C#- Unable to create instance of a class implementing from an interface I have: namespace someNamespace { public __gc class SomeClass1 { }
17
4790
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. ...
9
11552
by: keith | last post by:
I created a class libery which has name space Assembly and class Assembly and compiled it. Then created a C# project and called a method in the external class e.g. Assembly dll;...
2
1438
by: Stampede | last post by:
Hi guys 'n' girls, I would like to know if there is an easy way to load a class out of dll at runtime and create an instance of it. The class which should be loaded has a base class which is known...
7
3247
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
0
1515
by: Matt Howeson | last post by:
I have a problem with a usercontrol that is dynamically loaded, from a web control and is not restoring it's viewstate properly. Here's the scenario. Within our content management system, I have...
15
2392
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with...
6
1396
by: Ron M. Newman | last post by:
Hi, Under what circumstances can I ever get an exception about not being able to cast type "ABC" to type "ABC" if there's only one ABC class in the system and it's loaded from a dynamic...
4
4850
by: Mark S. | last post by:
Hello, I have a series of changing string IDs that are loaded dynamically a couple times a minute. I need to associate each ID with a different static class so later on in the app's lifecycle it...
0
7212
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
7098
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
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
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
5604
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
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
3186
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...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.