473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Dynamic Class Creation

I am trying to instantiate a new class using
Activator.CreateInstance(). The class is actually a window's form.
When the process executes the CreateInstance() method it generates an
exception. The exception states that it could not find an assembly.

In the original project that generated the dll, I added a reference to
the dll in the project (via Add Reference in the Solution Explorer
Pane of the IDE). Everything works in that project. Afterwards, I
recompiled it as a dll.

How would I go about solving the linking issue?

Thanks in Advance.

Sep 21 '07 #1
2 1389
Has the necessary .dll made it into the build-output of your main
project (usually under the "bin" folder)? Note that the compiler will
silently drop references that it detects aren't used by your code,
with the effect that it can get removed from the build-output.
Ensure "Copy Local" is set to true on the reference; if that doesn't
work, and the .dll is in your project-scope, then you can try changing
the build-action to "Component", or setting "Copy to Output Directory"
to true.

If the .dll is already there, then please indicate what are you
passing to Activator.CreateInstance()?

Marc
Sep 21 '07 #2
I tried the settings on the DLL files and it still could not find the
library. However, I included both the files in the resource.resx and
that seemed to have solved the issue of the library not being able to
resolve the missing library.

How I am calling the CreateInstance() method is passing in the type of
the construct. So the following:

Assembly myDLL = Assembly.LoadFile(path)
myObject = Activator.CreateInstance(myDLL.GetType("Namespace. MyClass")

Sep 21 '07 #3

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

Similar topics

3
by: Eddie de Bear | last post by:
Hi, A project I am working on has a requirement for dynamic menus. For the most part this works really well. The menus I'm creating a based on files and directories, so naturally the menu...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.10.2004 Hello, As far as I understand, the generic programming basically consists in using templates for achieving a static polymorphism of the various code fragments, and their...
1
by: andrew queisser | last post by:
I've been trying to dynamically create a class DevT that's derived from a generic base GenBase<T>. It doesn't seem to work. I'm attaching a code sample below that illustrates the problem. ...
15
by: rwf_20 | last post by:
I just wanted to throw this up here in case anyone smarter than me has a suggestion/workaround: Problem: I have a classic producer/consumer system which accepts 'commands' from a socket and...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
1
by: None | last post by:
Dynamic array creation Hi all... here's a good one for you... I have a situation where I have some bean, and I need to populate an array field in it... here's the problem... I do not know the...
1
by: dav3 | last post by:
Any help here is appreciated folks. First in my Person class the comments = errors visual basics is giving me and I am not sure why. Also when i try and set up my array of pointers to Student...
16
by: manatlan | last post by:
I've got an instance of a class, ex : b=gtk.Button() I'd like to add methods and attributes to my instance "b". I know it's possible by hacking "b" with setattr() methods. But i'd like to do...
3
by: arunank | last post by:
Hi, The following code for dynamic table creation is not working. Can anyone please help me. The dynamically created rows and columns are not getting populated. CODE: ========= <html>
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.