.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid
Post New Web Links

Private constructor

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

Is declaring a constructor private or declaring a class sealed is same thing??  Undecided

View Complete Post

More Related Resource Links

Private Constructor


In singlton pattarn , how , when the private constructor is called , pls give some practical example

default constructor SelectList




dont have a  default constructor

new SelectList() :(

Security: Protect Private Data with the Cryptography Namespaces of the .NET Framework


The .NET Framework includes a set of cryptographic services that extend the services provided by Windows through the Crypto API. In this article, the author explores the System.Security.Cryptography namespace and the programming model used to apply cryptographic transformations. He discusses reasons why cryptography is easier in .NET than it was before, including the easy programmatic acccess developers have to the cryptography APIs and the difference between symmetric and asymmetric algorithms. Along the way, a brief discussion of the most widely used algorithms, including RSA, DSA, Rijndael, SHA, and other hash algorithms, is provided.

Dan Fox

MSDN Magazine June 2002

Checkout/Chevk in issue in MOSS 2007 while connecting through VPN(virtual private network)


HI, I am using VPN connection . When I try modify a file and try to checkin the file in sharepoint document library it does not gets checked in. I get a message saying

"Unable to checkin the file, since File is being edited in Local Draft, please close the application or discard the checkout ".

Please do the needful....



Certificate API question - Private Key.

I am trying to follow http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.aspx but I am finding that the Private Key property of the certificate is always null. I created the certificate with makecert -pe -n "CN=BuySeasonsThirdParty" -r -b 08/26/2010 -e 08/26/2011 -sky exchange Amazon.cer. Then installing it on the local user store using: X509Store store = new X509Store(storeName, StoreLocation.CurrentUser); and using the same API to get the certificate from the store. The certificate that I retrieve from the store is non-null it is just the PrivateKey is null. So I can encrypt using something like: ((RSACryptoServiceProvider)cert.PublicKey.Key).Encrypt(Encoding.Unicode.GetBytes(text), true)   But since the Private Key property is NULL I cannot decrypt. Any ideas? Kevin


Any realtime example for constructor...???

System.Messaging - Error accessing properties of remote private queues - "UnsupportedFormatNameExcep

I'm having some difficulty accessing private queues on a remote machine, but no trouble using remote public queues or private queues on a local machine. Calling: System.Messaging.MessageQueue.GetPrivateQueuesByMachine("machine"); ..succesfully returns the array of private queues on the remote machine.  However, trying to access nearly all of the properties on these MessageQueue objects returns: MessageQueueErrorCode: UnsupportedFormatNameOperation Message:"The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted." I have no trouble accessing queues created identically on the local machine using GetPrivateQueuesByMachine("."), plus accessing public queues using GetPublicQueuesByMachine("machine") also returns MessageQueue objects that are useable. The FormatName returned appears to be valid, as you would expect from queues retreived via GetPrivateQueuesByMachine().  e.g: FormatName:Direct=OS:machine\\private$\\example ..so I think the error message returned may be somewhat spurious. The permissions on the queues all appear to be set correctly.  I had even attempted allowing "Full Control" to "Everyone" on these queues as an experiment, with the same results. Any ideas for other things I might try? p.s. I am running Windows XP SP2, using .NET 2.

Private Security Model Integration

Does anyone have any recommendations on tieing the Microsoft AS security model in with an independent security model. We are at the beginning process to discuss this with a very large international partner and are looking for recommendations form anyone who has done this before. Thanks in advance Alan

MSSQL CE 3.5 SP2 Private Deployment

I use Visual C# express 2008 for my development.  I use MSSQL CE3.5 SP1 and have deployed this will my application for over a year as a private deployment (just included all the DLLs in my project).  This has worked well and kept me from being dependent on the product deployments.  I am running into an issue with the application deploying on Windows 7 64-bit home edition.  From my readings it seems that I need to upgrade to the MSSQL CE 3.5 SP2 but the indication is that I need to deploy 32-bit and the 64-bit SP2 for the 64-bit environements.  Since my development environment is on Windows XP I have not found a way to obtain the 64-bit version of the DLLs to include in my project as a private deployment.  Can I do this?  Is there a better way?  Where can I get the 64-bit DLLs. Thanks in advance for any help anyone can provide.David Allen

Referenced WebService, class constructor with parameters

Hi, I have WebService which is referenced in C# ClassLibrary project. In WebService project I have a class named User, which has two constructors - one without parameters and one whith parameters. When I try to create instance of User class from WS in ClassLibrary, I can use only constructor with parameters. My question is, how can I use in constructor with parameters like User u = new User("some@email.com", ...);. Any idea? Thansk

System.Uri constructor. Bug or my misunderstanding?

Hello. I use this Uri constructor: Uri (Uri, String). Base uri refers to: https://admin.fedoraproject.org/updates/F13/security?_csrf_token=bfd822860e8c532850b9ba817aebecbefdd490be and ?updates_tgp_no=2&_csrf_token=e075a5525532054a2e0f58c4674f875a6779b37a&updates_tgp_limit=25 stands for the relative address. What should be the target uri? I believe it is : https://admin.fedoraproject.org/updates/F13/security?updates_tgp_no=2&_csrf_token=e075a5525532054a2e0f58c4674f875a6779b37a&updates_tgp_limit=25 but I get https://admin.fedoraproject.org/updates/F13/?updates_tgp_no=2&_csrf_token=e075a5525532054a2e0f58c4674f875a6779b37a&updates_tgp_limit=25 so 'security' is omitted. Can anybody tell me why it's so?

Custom Authenticate Attribute with Constructor (Dependency) Injection

  I have a [BeastAuthenticate] attribute on my controller.  The following code works fine but I would like to use Contructor (Dependency) Injection with Unity.  The problem is that the attribute will run the contructor with no parameters.  Interfaces ITMSLogger and IADGroups are setup to use Dependency Injection with TMSLogger and ADGroups respectively.   The following code works fine but doesn't use dependency injection for class ADGroups. public class BeastAuthenticateAttribute : AuthorizeAttribute { private ITMSLogger logger = new TMSLogger(); public BeastAuthenticateAttribute() { ADGroups adGroups = new ADGroups(logger); Roles = adGroups.GetRolesWithGroup("BEAST"); } } I tried the following but I'm getting an error ("Object reference is required...") with "this (adGroups). public class BeastAuthenticateAttribute : AuthorizeAttribute { private ITMSLogger logger = new TMSLogger(); private IADGroups adGroups;// = new ADGroups(new TMSLogger()); public BeastAuthenticateAttribute() : this (adGroups) { // adGroups = new ADGroups(logger); // this(adGroups); } public BeastAuthenticateAttribute(IADGroups adGroups) { //ADGroups adGroups = new ADGroups(l

Question about RSA Decrypt using private key

Hello,      I am doing a project to communiate with a bank. I send a message which was sign by my private key to the bank and get a response from the bank. The message like below: PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iR0JLIj8+CjxtZXNzYWdlIG1ldGhvZD0iZXJyb3IiIHR5cGU9InJlc3BvbnNlIj4KICAgIDxkYXRlPjIwMTAwNTI4PC9kYXRlPgogICAgPHRpbWU+MTEwMzQ1PC90aW1lPgogICAgPHJldENvZGU+QVVUSDBFSTwvcmV0Q29kZT4KICAgIDxjb21tZW50UmVzPuacquW8gOWNoTwvY29tbWVudFJlcz4KPC9tZXNzYWdlPgo= Then I try to decrypt the message. The code like below:        public static string ParsePayment(HttpRequest request)     {         string CertificatePW = "123456";         string prikey_path = HttpContext.Current.Server.MapPath("~/App_Data") + "\\certificate\\test.pfx";         return CerRSADecrypt(Convert.FromBase64String(aa), prikey_path, CertificatePW);          }         public static string CerRSADecrypt(byte[] DataToDecrypt, string prikey_path, string CertificatePW)     {                        &nbs

Error - No parameterless constructor defined for this object.

I am doing Music Store sample application.Here my code.StoreViewModel public class StoreManagerViewModel { public Album Album { get; set; } public SelectList Artists { get; set; } public SelectList Genres { get; set; } } StoreController public ActionResult Create() { var Artists = storeDB.Artists; var Genres = storeDB.Genres; StoreManagerViewModel model = new StoreManagerViewModel() { Album = new Album(), Artists = new SelectList(Artists, "ArtistId", "Name"), Genres = new SelectList(Genres, "GenreId", "Name") }; ViewData["Artists"] = model.Artists; ViewData["Genres"] = model.Genres; return View(model); } [HttpPost] public ActionResult Create(StoreManagerViewModel model) { try { if (ModelState.IsValid) { Album album = new Album() { Title = model.Album.Title, Price = model.Album.Price, ArtistId = Convert.ToInt32(model.Artists.SelectedValue), GenreId = Convert.ToInt32(model.Genres.SelectedValue),

WPF app never appears if showing a MessageBox during App constructor!?

My App class' constructor calls a method called initDataStructures. Here I want to load a file with data if it exists. However, as always, it's not guaranteed I can access the file - in my case, the most likely situation (it's a CSV file) is that the file is open in Excel. In this case I would like to show a dialog box, and the user can then choose to ignore the problem (and lose previously saved data) or exit the application (to try again after taking some action, such as closing the file in Excel). This code is in initDataStructures(), called from the App constructor: if (File.Exists(SubmissionsFileName)) { try { using (var reader = new CsvReader(File.OpenRead(SubmissionsFileName), ';')) { ... } } catch (IOException ex) { //string nl = Environment.NewLine; //string msg = "IOException caught while attempting to load previously recorded submissions. " // + "Press OK to ignore (lose previously saved submissions), Cancel to exit. " + nl + nl // + "Message: " + nl + nl + "{0}"; //var response = MessageBox.Show(string.Format(msg, ex.Message), "Loading error", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //if (response == MessageBoxResult.Cancel) //{ // submissions = null; // Shutdown(); //} } } If I uncomment the commented li

Exception when initializing private key from xml string (RSACryptoServiceProvider using FromXmlStrin

Hi, I'm trying to create a private key using the following code segment   System.Security.Cryptography.AsymmetricAlgorithm key = new System.Security.Cryptography.RSACryptoServiceProvider();string privateKeyXml = File.ReadAllText(fullPathPrivateKey);key.FromXmlString(privateKeyXml);   It does work with .NET Framework 3.5 SP1 on Windows XP, but when I try to run it on .NET Framework 4.0 on Windows 7 I get the following exception ((System.Security.Cryptography.RSACryptoServiceProvider)(key)).CspKeyContainerInfo.Exportable' threw an exception of type 'System.Security.Cryptography.CryptographicException', with message "Key does not exist". Full stack trace is shown below: System.Security.Cryptography.CryptographicException: Key does not exist. at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) at System.Security.Cryptography.Utils._GetProviderParameter(SafeProvHandle hProv, Int32 keyNumber, UInt32 paramID) at System.Security.Cryptography.CspKeyContainerInfo.get_Exportable() Does anyone have a clue to why this doesn't work on .NET 4.0? Regards, Simon
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend