473,395 Members | 1,987 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,395 software developers and data experts.

Have an error to use a string combined into a path to run the object

1
Hello guys~

I got problem
this is my code:

Expand|Select|Wrap|Line Numbers
  1.      MainForm mainForm = this.ParentForm as MainForm;
  2.      string strassemblyName = string.Empty;
  3.  
  4.      strassemblyName = "PowerOne.Win.Order".ToString();
  5.      //Assembly
  6.  
  7.      System.Reflection.AssemblyName assemblyName = new System.Reflection.AssemblyName();
  8.  
  9.      assemblyName.Name = strassemblyName;
  10.  
  11.      AppDomain appDomain = AppDomain.CurrentDomain;
  12.      System.Reflection.Assembly tmpass = appDomain.Load(assemblyName);
  13.  
  14.      CustomerTypeEdit form =            (CustomerTypeEdit)tmpass.CreateInstance("PowerOne.PowerOne.Win.Order.CustomerTypeEdit", true);
  15.  
  16.      form.Show();

But this "form" is still null
Who can help me to fix it?????
Oct 20 '10 #1
2 1151
Curtis Rutland
3,256 Expert 2GB
I've used the static class Activator to create instances from an assembly qualified name before.

For example:
Expand|Select|Wrap|Line Numbers
  1. string aqn = "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
  2. Type type = Type.GetType(aqn);
  3. int i = (int)Activator.CreateInstance(type);
  4.  
Look at how the AssemblyQualifiedName is put together. "Full.Namespace.ClassName, Assembly.Name, Version, Culture, PublicKeyToken".

You can find the AQN with this code:
Expand|Select|Wrap|Line Numbers
  1. Console.WriteLine(typeof(Int32).AssemblyQualifiedName);
You just need to plug in the type of the object you're using.
Oct 20 '10 #2
What are you trying to do?
You can get path of your currently executing assembly using:

Expand|Select|Wrap|Line Numbers
  1. Assembly.GetStartUpPath();
  2.  
Oct 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: The Plankmeister | last post by:
Hi (again) I'm purposely generating an SQL error to test my aforementioned custom error handling function, but I encounter a strange problem. The error string generated by my forced error is: ...
1
by: Cyper Hunter | last post by:
Hi: Do you know how to change the url string of URL object? For example, I have an URL object declared as: URL myurl = new URL("http://www.cnn.com"); How to change the url string of myurl...
1
by: Elie B. | last post by:
Hi, I'm new to Python. I'm trying to embbed Python in my Windows application having some success with redirecting the stdin/out to my windows application using: In my C++ code I use...
1
by: Ganesh J. Acharya | last post by:
Shree Ganesha Error at Map Path System.Mappath() Please tell me a walk around for system.mappath("../database/data.mdb") my files are already configured with this path now windows 2003...
5
by: miki | last post by:
Hi all, How can I cast from a string to an object? For example, suppose I have classes as employee, manager, supervisor, director,...I have a user interface that takes a person name, then...
8
by: GlennDoten | last post by:
I just happened to be looking through the implementation of the System.Version class in the SSCLI and one of the constructors starts like this: public Version(String version) { if ((Object)...
0
by: Wouter vanEck | last post by:
Hi All, I have the following problem, I have a string for example "<table><tr></td><MyTextBox /></td></tr></table>" which is created by a user typing in a textbox. Now I like to take that...
0
by: nycers_developer | last post by:
Error number 429 - COM object with CLSID {000209F0-0000-0000-C000-000000000046} is either not valid or not registered. Intermittent occurance of this error. Using Word.Global to run word macro...
2
by: bb | last post by:
when using the web deployment project to merge my aspnet assemblies i get an unusual error 'access to path denied' i double checked path looks ok, and gave everyone full perms on the folder and...
8
by: Daz | last post by:
Hi Everyone. I am sturggling trying to find out a way in which I can delete a 'path' object. I may not need to delete it, however, I need to overwrite it. The function I am trying to code,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.