PC Review


Reply
Thread Tools Rate Thread

Application.UserAppDataPath - NullReferenceException

 
 
Anders Eriksson
Guest
Posts: n/a
 
      11th Feb 2011
Just "upgraded" from VS2008 Pro to VS201 Express and when I try to run
an old program (that I have recompiled with VS2010) I get an
NullReferenceException on this scode:

[STAThread]
static void Main()
{
// Check for existing instance
bool firstInstance = false;
string safeName = Application.UserAppDataPath.Replace(@"\", "_");
Mutex mutex = new Mutex(true, safeName, out firstInstance);
if (!firstInstance)
return;

// Start only instance
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

The exception is on this line:

string safeName = Application.UserAppDataPath.Replace(@"\", "_");

The exact same code works prefectly in VS2008
What has changed and how do I fix it?

// Anders
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DeploymentException when accessing Application.UserAppDataPath property cody Microsoft VB .NET 0 21st Aug 2007 10:35 PM
DeploymentException when accessing Application.UserAppDataPath cody Microsoft Dot NET 0 20th Aug 2007 09:29 PM
Application.UserAppDataPath Question David White Microsoft Dot NET Framework 2 1st Mar 2006 01:38 PM
Application.UserAppDataPath without ProductVersion at the end ofthe path? SharpCoderMP Microsoft Dot NET Framework Forms 0 18th Jan 2006 03:06 PM
Retriving Application.UserAppDataPath without creating it Matt Budd Microsoft C# .NET 1 26th Mar 2004 07:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 PM.