473,405 Members | 2,344 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,405 software developers and data experts.

System.Activator class problem

Hi,

Why it is not possible to create an instance for System.Activator class. It
is saying that "member is inaccessible due to its protection level", in
compilation. Acutally it is a public sealed class. It is possible to create
an instance of my own public sealed class.

Can anybody explain me Why?

Thanks in advance.

Regards
Sabari.
Jul 21 '05 #1
3 1396
Can anybody explain me Why?


Does your class have a default public constructor?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 21 '05 #2
Hi,

My sealed class doesn't have any default constructor.
The below is my class:

using System;

namespace TestLib
{
/// <summary>
/// Summary description for SealedClass.
/// </summary>
public sealed class SealedClass
{
public static string Display()
{
string s = "hai";
return s;
}
}
}

Thanks.

Regards,
Sabari.

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:#M**************@TK2MSFTNGP09.phx.gbl...
Can anybody explain me Why?


Does your class have a default public constructor?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Jul 21 '05 #3
Sabarinath <sa*******************@isoftplc.com> wrote:
My sealed class doesn't have any default constructor.


Yes it does. Unless you specify any constructors at all, you get a
public parameterless one.

However, that doesn't sound like the problem - the problem is that
Activator *doesn't* have a public constructor - you're not meant to
instantiate it. Why are you trying to?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

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

Similar topics

0
by: Angelos Karantzalis | last post by:
Hi y'all, here's a tricky one: I've written a wrapper around a Com Interop-generated assembly in C#. It's called SDEHandler & implements a previously defined interface, so that I can use it as a...
0
by: philipl | last post by:
hi, i am having a problem catching a user defined exception, defined in a class A library on its own, thrown from another class B. I am trying to catch it in a console app which invokes class B...
1
by: John Jenkins | last post by:
Hi, I have a fairly simeple question. What are the differences between Assembly.CreateInstance and System.Activator.CreateInstance? I had read that one maps to the other, however when I use...
3
by: System.Reflection Activator | last post by:
************************************** //Load the Assembly Assembly a = Assembly.LoadFrom(sAssembly); //Get Types so we can Identify the Interface. Type mytypes = a.GetTypes(); BindingFlags...
7
by: Ian Frawley | last post by:
Hi I have used the Activator class a number of times in my Windows apps and Windows Services and was thinking of using it again in one of my web services that I have been developing. I have been...
0
by: Steve B | last post by:
Forgive my ignorance on this subject; I'm just starting to use .NET. I have a plug-in manager written in managed c++ with the following code: namespace MySDK{ public __gc __interface IPlugIn{...
3
by: Sabarinath | last post by:
Hi, Why it is not possible to create an instance for System.Activator class. It is saying that "member is inaccessible due to its protection level", in compilation. Acutally it is a public...
1
by: Johnny R | last post by:
Hello, I'm loading a Class from Assemly DLL using Activator.CreateInstance. That loaded Class is executed in a worker Thread with no loop. What actually happends when class is loaded using...
7
by: WTH | last post by:
I am now aware (I am primarily a C++ developer) that in C# if you reference the same interface from the same file in two different projects the types are actually incompatible. I found this out...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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.