473,320 Members | 1,904 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,320 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 1392
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.