473,805 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TypeInitializat ionException thrown

6 New Member
Hi,

i hav two classes as following;

class1.cs
----------
namespace NAS
{
// fields
// properties

public class Class1
{
public Class1() {}
}

// member methods
// ...
}



class2.cs
-----------
namespace NAS
{
public class Class2
{
private Class1 class1Obj;

public void Meth()
{
class1Obj = new Class1(); // here i get an error
} // it throws TypeInitializat ionException
}
}

when i create an object of Class1 under Class2, i m getting
TypeInitializat ionException.
But i hav referred the class corretly in Reference..

Please help me..
NAS
Feb 2 '07 #1
1 1493
RedSon
5,000 Recognized Expert Expert
This looks right. Have you included class1 in your class2 project? Class2 must know what a Class1 object is and how to create one. Here is some additional information about Classes for C#.
Feb 2 '07 #2

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

Similar topics

1
6399
by: Ethan | last post by:
I made a program that works fine as long as its on my machine, but as soon as i move it to a network drive it stops working. I'm still trying to run it on my machine just from a network drive and it gives me system.typeinitializationexception. Anyone know what changes when i move it to a network drive and try running it from there? I have also tried running it on a machine with .net
1
2273
by: sys | last post by:
I made a smart client that I purposed to offer on a web server. But when I try to run it by dint of Internet Explorer, I get the System.TypeInitializationException in the IEExec.exe thread. My exe is signed and has full trust on my computer. And when I start the programm directly (C:\Inetpub\myfolder\sample.exe) it works fine. Has somebody an idea?
0
1592
by: cnu | last post by:
Hi, I have a windows form application that works well in my computer in debug and release modes from IDE and windows explorer. I do XCOPY deployment on other computer. When I run the applicaiton there, it gives System.TypeInitialization exception. As expected, this exception is thrown when I call a class with only public static variables...no constructors, propterties and methods. How can I solve this issue?? Please help me
0
1654
by: Sagaert Johan | last post by:
this code using System; using System.Net.Sockets; namespace ConsoleApplication1 { /// <summary> /// Summary description for Class1. /// </summary>
1
1260
by: Roshan Hadal via .NET 247 | last post by:
We are able to run our application succesfully through .Net IDE.When we try to run the .EXE of the same(created and installedthrough SetUp package) a type initialization exception(System.TypeInitializationException) is thrown. Our applicationis multi-threaded. We think it may be due to Win App. securityreasons, so it runs properly through IDE but when we try todeploy and run the .EXE it throws the above exception mentioned.What suggestions can...
3
3711
by: linaj | last post by:
Hi, I have singleton class in C#: class Logger { static Logger lInstance = new Logger(); private Logger() {}
18
7131
by: Zytan | last post by:
I just got a TypeInitializationException exception. Why it is a common cause for this? The InnerException is System.FormatException, although I don't see anything requesting something to be formatted. I'm trying to invoke the use of a class, to force its static c'tor to run, which will run its unit test. Is there a good way to force all class's static c'tors to be run on startup?
0
601
by: =?Utf-8?B?TWFyY3VzIFNjaGFlZmVy?= | last post by:
Hi everybody, I'm working on my application for appr. 2 years and now suddenly I got an System.TypeInitializationException in one of my global modules. The error is thrown at the first call of a subroutine out this module. The code I was programming isn't related in any way with this module and I even hadn't loaded this module into the dev. enviroment the first time the error occured.
1
2258
by: =?Utf-8?B?UGhpbGlwIFdhZ2VuYWFy?= | last post by:
I have an ASP.NET application that is showing throwing an strange exception in my Virtual PC environment. We have encoutered this error at a customer running our product on Virtual Server. At the customer we solved the problem by giving the Page File a fixed size. This solution does not work in my Virtual PC environment. I have searched on the exception that is thrown but cannot find anything related on the web. So to be honest. I have...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10369
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
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.