Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Speed up Visual Studio in few easy steps

1. Delete C:\Users\[username]\AppData\Local\Microsoft\WebSiteCache content
2. Delete C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files content
3. Uncheck Tools -> Options -> Debugging -> Edit and Continue -> Enable Edit and Continue
4. Uncheck Tools -> Options -> Environment -> Use hardware graphics acceleration if available

Visual Studio - Pre or Post-build events - copying example

The Pre or Post events are simple and useful actions before or after building the solution, which can be used for performing customized actions to simplify deployment or testing.

The following example copying all output files to myproject\bin located in the solution directory.
Ex.
copy "$(TargetDir)*.*" "$(SolutionDir)myproject\Bin"

For reference see Macro table in MSDN

Batch files can be used as well for more complex predefined actions using the call statement Ex. call C:\Batch.bat

How to build unsafe C# code with Visual Studio

Unsafe code may only appear if compiling with /unsafe

This appears as an error when you try to compile assembly which contains unsafe code in release mode.
You must change the compiler options using project's Properties page -> Build -> and check Allow Unsafe Code. Consider if you want to use unsafe code :)))

Error rendering a custom control

Maybe this is a little MS Visual Studio bug. It is connected to the control registering in the page in case of using a control defined in App_Code folder, not in another assembly. The exception thrown while opening design view of the page is:

Error Rendering Control - [control] An unhandled exception has occurred. There was an error parsing the theme. The assembly attribute cannot be an empty string.

So the VS environment doesn't recognize the control defined in the App_Code. Therefore the control regitration must inlcude the assembly name - "App_Code"

<%@ Register TagPrefix="my" Namespace="MyControls" assembly="App_Code" %>

or

<add tagPrefix="my" namespace="MyControls" assembly="App_Code" />
in web.config - pages/controls section

SQL Server Express Edition attaching and using problems

"Cannot open user default database. Login failed.
Login failed for user ......"

This problem occurs very often while the developer uses Visual Studio and testing in a browser at the same time. The reason is the already opened connection to the database in the VS environment. For example every time when the developer edit DataSet connected to current database this connection stays opened. The solve this problem the connection to the db has to be closed by the right mouse button -> Close Connection in the Server Explorer tab.

Another problem with attaching database and using its connection is:
"An attempt to attach an auto-named database for file ..... failed. A database with the same name exists, or specified file cannot be Opened, or it is located on UNC share."

1 . The first thing that has to be done is to try to attach the database manually with Microsoft SQL Server Management Studio.

2. The data folder permissions have to be set to "Modify" for ASPNET account and NETWORK SERVICE for windows server 2003

3. Make ASPNET user a member of SQLServer2005MSSQLUser$server$SQLExpress group

4. Add new Login to the SQL Express server for ASPNET (NETWORK SEVICE) user

5. In the connection string User Instance=True has to be checked. It works only if SQL Server uses Windows Authentication mode.
Changing the authetication mode can be done by SQL Server Management Studio with right mouse click on the computer name and Properties -> Security.
When Integrated Security=SSPI in the connection string is used make sure you are using in system.web sections of the web.config and also make sure that a windows account for the "Anonymous User" is selected in the access section in IIS.

6. Also the sql settings in
c:\Documents and Settings\<username>\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\ can be deleted and the sql service restarted.

How to use SQL SERVER 2005 with SQL EXPRESS at the same time.

Error message received by Visual Studio 2005:
"Connections to sql server files (*.mdf) require sql server express 2005 to function properly"
I had installed Visual Studio 2005 and SQL Server 2005 Developer Edition when I received it. To solve the porblem I installed other instance of SQL Server - Express Edition. But to get VS to work with it I had to change its instance name in the VS options. Tools -> Options - > Database Tools -> Data Connections. Now I can work with the two sql server instances - Developer Edition and Express Edition.


To change an existing instance of Microsoft SQL Server 2005 to a different edition of SQL Server 2005, you must run SQL Server 2005 Setup from the command prompt and include the SKUUPGRADE=1 parameter.

Default Web Site on IIS doesn't work until changing the default port.

It is a very strange problem that occurs sometimes.
"IS Unexpected error 0x8ffe2740"
Today I have just found the reason - Skype is using the default port 80 for alterantive connection.
Resolve that by:
Skype File, Options, Advanced, Connection
Uncheck "Use Port 80 as an alternatives for incoming connections" and restart default website or IIS

VS 2005 Required components missing

Problem: Visual studio 2005 cannot connect to sql server express database. This is so boring problem... Here is a short summarize of similiar issue:
http://www.sqljunkies.com/WebLog/ktegels/archive/2005/11/15/17401.aspx

However my problem continued. The reason was that I have had installed Standard Edition of Sql Server 2005. When I installed SQL Server Express Edition I received the problem. The solution I found was so simple, I had to change database options of Visual Studio:
Tools -> Options -> Database Tools -> Data Connections. I changed SQL Server Instance Name to the new instance name (name of sql server express edition). This needed restart of Visual Studio. Now it works fine :-)

VS 2005 "Extensibility DTE object unavailable"

This occured after removing Visual Studio .NET 2003. When I trying to show dataset I recieved this error message.
I read many posts for this problem but the only way I found was repairing VS. This didn't solve the my problem. It was neccessary to remove totally VS 2005 and install it again.

Visual Studio 2005 - If there isn't Database Name File for Access database file

You have to change a registry key:


HKEY_CLASSES_ROOT\CLSID\{F9AE8980-7E52-11d0-8964-00C04FD611D7}

Underneath this key should be a sub-key called "ProgID" with a value of "MSIDXS.1". If you can't find this, it is causing the problem you are seeing. Adding this back should fix the issue.

Visual Studio - 'Unable to get the Project file from the Web server'

A solution to the 'Unable to get the Project file from the Web server' that has worked for us is to go into C:\Documents and Settings\(your user)\VSWebCache and delete everything in there."