开发者

Why do "I get Failed to generate a user instance of SQL Server" with .NET 4 and not .NET 2?

I have created on my local machine with targetframework 4 in visual studio a simple website using the de开发者_StackOverflow中文版fault template (the one with css problem solved here Google Maps API in ASP.NET Masterpage: why it stays blank?)

I uploaded it to my IIS 7 server which was first configured for .NET 2 so in web.config I deleted the line

<compilation debug="false" targetFramework="4.0" />

so that it can run on .NET 2.

Until then that was fine.

Then I edited in ISS7 my website to use .NET 4. When testing the site again, I got this error:

Failed to generate a user instance of SQL Server due to 
failure in retrieving the user's local application data path.

I hadn't told you that I didn't install any sql server yet so this message may be normal but why didn't I get it with .NET 2 ? Could I configure something in .NET 4 so that this error is ignored like on .NET 2 ?


When a user logs in for the first time a profile is created on disk for example in c:\users\username.

If you are in the security context of a user that has never logged in to that machine in a way that creates the profile, and you try to write information to the profile, you get a sort of "directory does not exist error".

There must be a difference in the security context between .net 2 and 4.


It is rather difficult to understand what you are doing and why

"I hadn't told you that I didn't install any sql server yet"

Visual Studio (VS) installs SQL Server Express (configured, by default, for local use only, remote one should be enabled) but IIS7, ASP.NET or Windows doesn't

"I have created on my local machine with targetframework 4 in visual studio a simple website using the default template"

If you created a project targeting ASP.NET4.0, you cannot run it with ASP.NET 2.0 (you can do it vice versa, to run in 4.0 created for 2.0)

Which default template? They are configured in VS after or during VS setup

"Failed to generate a user instance of SQL Server"

User instance of SQL Server is created during ASP.NET project creation in VS2010 targeting 4.0 which you do not have on uploaded machine (you may check that folders and files for ASP.NET membership are created using SQL Server USer Instance). They are not created by project targeting 2.0

What is the sense of creating ASP.NET 4.0 project and then test it in ASP.NET2.0 machine? Create it targeting 2.0 from the scratch.

-- Update:
This is common software principle called backward compatibility - the software knows and can accommodate for previous (in 2.0 for 3.0, 1.0, 1.1) but not for future differences (in 2.0 for 4.0)
http://en.wikipedia.org/wiki/Backward_compatibility

You can create project targeting 2.0 and change for 4.0 later on or do not use Visual Studio at all if you are uncomfortable with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜