.NET Developers Q&A (RSS)

.NET Development: Questions and Answers.

PRB: Using Jet provider on 64-bit machines

If you experience the error message:

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

this is caused by the Jet provider not being available in native 64-bit.

You will have to target x86 with your .NET apps to make it work.

with 0 Comments

Optimizing VMware virtual machines with PerfectDisk 2008 grows, instead of shrinks, the virtual disk

Prerequisites:

 

Situation:

  • After "optimizing" the VM the file grows (in my case from 13 GB to 100 GB, which is the maximum size of the dynamic disk)

 

Workaround:

  • Create a full clone of your VM (this copies all the linked disks + your VM into a target disk). You are not using the base disks from that moment on. But the resulting VM will be nice and small and in the future you can use PerfectDisk again to optimize and shrink your VM.

 

Background:

  • VMs with linked disks are not available for SHRINK operations.
  • WIthout linked disks this works perfectly.
with 0 Comments

Not enough free space to create a full clone out of a linked clone with VMware

Situation:

  • You have a linked clone.
  • You do not have any snapshots, just the current state.
  • You want to create a full clone out of the base image(s) and the current state using the VMware Wizard.
  • You get the error message that you need (3.5 GB) of free hard drive space.
  • Freeing space on the source and target drive does not seem to help.

Solution

  • Just create a snapshop and re-try the full-clone-creation.

Enjoy!

with 0 Comments

A central place for Visual Studio hot fixes

can be found here:
http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?TagName=Hotfix

with 1 Comments

WORKAROUND: Installing Windows SDK for Windows Server 2008 and .NET Framework 3.5 breaks your XAML Intellisense

A nasty one, you will probably realize in front of customers.

The workaround can be found on the Windows SDK blog.

Enjoy!

with 0 Comments

Using LINQ to SQL with SQL Server Compact Edition

If you try to drag tables from the Server Explorer of Visual Studio 2008 to the designer surface of the Link-to-SQL designer you'll probably be surprised to see the error message stating:

"The selected object(s) use an unsupported data provider"

However you can use SqlMetal.exe to generate the .dbml file manually (obviously: command line instead of drag & drop).

with 0 Comments

INFO: Edit and Continue works only against .NET apps that target 32-bit (x86)

You cannot use Edit and Continue on a Windows 64-bit machine by default.

Workaround: For development and testing change the target platform from "Any CPU" to "x86" in order to get Edit and Continue support.

with 1 Comments

Workaround: Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

If you get that nice error message change your solution configuration to target 32-bit (x86) using configuration manager.

For more information read this.

with 0 Comments

FIX: Performance too slow when doing web development with Visual Studio 2008?

Microsoft released a hotfix [1] for Visual Studio 2008 (also targeting Visual Web Developer Express) that corrects several issues with the web development features.

At this time the hotfix is only available for the English and Japanese versions.

List of things that were corrected according to this post [2] by Vinaya Reddy:

HTML Source view performance

  • Source editor freezes for a few seconds when typing in a page with a custom control that has more than two levels of sub-properties.
  • “View Code” right-click context menu command takes a long time to appear with web application projects.
  • Visual Studio has very slow behavior when opening large HTML documents.
  • Visual Studio has responsiveness issues when working with big HTML files with certain markup.
  • The Tab/Shift-Tab (Indent/Un-indent) operation is slow with large HTML selections.

Design view performance

  • Slow typing in design view with certain page markup configurations.

HTML editing

  • Quotes are not inserted after Class or CssClass attribute even when the option is enabled.
  • Visual Studio crashes when ServiceReference element points back to the current web page.

JavaScript editing

  • When opening a JavaScript file, colorization of the client script is sometimes delayed several seconds.
  • JavaScript Intellisense does not work if an empty string property is encountered before the current line of editing.

Web Site build performance

  • Build is very slow when Bin folder contains large number of assemblies and .refresh files with web-site projects.

Make sure to read the installation instructions at [2].

Enjoy!

[1] https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826

[2] http://blogs.msdn.com/webdevtools/archive/2008/02/09/downloadable-hotfix-performance-and-editor-fixes-for-microsoft-visual-studio-2008-and-visual-web-developer-express-2008.aspx

with 0 Comments

Comparing special folders returned by Environment.GetFolderPath between Windows XP and Vista

The program

class Program
{
  static void Main(string[] args)
  {
    foreach (System.Environment.SpecialFolder value in Enum.GetValues(typeof(System.Environment.SpecialFolder)))
  {
    Console.WriteLine(Enum.GetName(typeof(System.Environment.SpecialFolder), value) + " = " + System.Environment.GetFolderPath(value));
    }
  }
}

The output on Windows XP

Desktop = C:\Documents and Settings\Neno\Desktop
Programs = C:\Documents and Settings\Neno\Start Menu\Programs
Personal = D:\My Documents
Personal = D:\My Documents
Favorites = C:\Documents and Settings\Neno\Favorites
Startup = C:\Documents and Settings\Neno\Start Menu\Programs\Startup
Recent = C:\Documents and Settings\Neno\Recent
SendTo = C:\Documents and Settings\Neno\SendTo
StartMenu = C:\Documents and Settings\Neno\Start Menu
MyMusic = D:\My Documents\My Music
DesktopDirectory = C:\Documents and Settings\Neno\Desktop
MyComputer =
Templates = C:\Documents and Settings\Neno\Templates
ApplicationData = C:\Documents and Settings\Neno\Application Data
LocalApplicationData = C:\Documents and Settings\Neno\Local Settings\Application Data
InternetCache = C:\Documents and Settings\Neno\Local Settings\Temporary Internet Files
Cookies = C:\Documents and Settings\Neno\Cookies
History = C:\Documents and Settings\Neno\Local Settings\History
CommonApplicationData = C:\Documents and Settings\All Users\Application Data
System = C:\WINDOWS\system32
ProgramFiles = C:\Program Files
MyPictures = D:\My Documents\My Pictures
CommonProgramFiles = C:\Program Files\Common Files

The output on Windows Vista

Desktop = C:\Users\Neno\Desktop
Programs = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Personal = C:\Users\Neno\Documents
Personal = C:\Users\Neno\Documents
Favorites = C:\Users\Neno\Favorites
Startup = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Recent = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Recent
SendTo = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\SendTo
StartMenu = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Start Menu
MyMusic = C:\Users\Neno\Music
DesktopDirectory = C:\Users\Neno\Desktop
MyComputer =
Templates = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Templates
ApplicationData = C:\Users\Neno\AppData\Roaming
LocalApplicationData = C:\Users\Neno\AppData\Local
InternetCache = C:\Users\Neno\AppData\Local\Microsoft\Windows\Temporary Internet Files
Cookies = C:\Users\Neno\AppData\Roaming\Microsoft\Windows\Cookies
History = C:\Users\Neno\AppData\Local\Microsoft\Windows\History
CommonApplicationData = C:\ProgramData
System = C:\Windows\system32
ProgramFiles = C:\Program Files
MyPictures = C:\Users\Neno\Pictures
CommonProgramFiles = C:\Program Files\Common Files

Note: On the Window XP machine the My Documents folder was moved to drive D.

with 0 Comments

svcutil /dconly results in 'Error: The input read from 'http://localhost/MyService.svc?wsdl' is inconsistent with other options.'

Larry asked in the MSDN Forums why the following command line:

svcUtil http://localhost/MyService.svc?wsdl /dconly

raises this error:

Error: The input read from 'http://localhost/MyService.svc?wsdl' is inconsistent with other options.

 The essential note is stated in the Windows SDK Release Notes (Link):

5.4.11 Service Model Metadata Utility Tool (SvcUtil.exe) Can’t Generate Data Contracts from a Running Service

An example at the end of the svcutil.exe help output indicates that you can use the /dataContractOnly (/dconly) option to generate Data Contracts from a running service:

svcutil /dconly http://service/metadataEndpoint
- Generate Data Contract types from a running service or online metadata documents.

This usage does not work. You can only use the /dconly option to generate Data Contracts from local metadata files.

with 2 Comments

File System transactions with Windows Vista

I often see people staring at the slides where it states Vista (and Windows Server 2008) does have a transactional files system and registry.

Yes, it’s true and you can read find out more in this MSDN Magazine article.

with 0 Comments

Don't like the vshost.exe? You can turn it off!

Dominick [1] pointed me a great tip today how to turn of the hosting process (vshost.exe) [2]. This might be interesting for those of you who are debugging applications on Windows Vista with UAC manifests, which sometimes has strange side effects.

[1] http://www.leastprivilege.com/

[2] http://msdn2.microsoft.com/en-us/library/ms185330(VS.80).aspx

with 1 Comments

FIX: .NET Framework 1.1, SendKeys and Windows Vista

Microsoft released an update for enabling .NET Framework 1.1 applications to use the SendKeys command under Windows Vista without experiencing the "Hook cannot be created" error message (as explained in this KB article).

with 1 Comments

[ClickOnce] Using the ClickOnce Publish Wizard on Windows Vista

The ClickOnce publishing Wizard on Windows Vista generates the following error message:

"Failed to connect to 'http://localhost/WindowsApplication1/' with the following error: Unable to create the Web 'http://localhost/WindowsApplication1/'.  The Web server does not appear to have the FrontPage server extensions installed."

To solve this you need to do two basic things (thanks to my thinktecture colleague Dominick Baier):

  • Configure IIS to run in IIS6 Compatibility Mode.
  • Run Visual Studio as an Administrator.

Read the whole story (at Brian Noyes' Blog).

with 0 Comments

ClickOnce Deployment Error: "Proxy authentication required" - Fix available

Did you use ClickOnce with .NET Framework 2.0 and got the error message "Proxy authentication required"?

Are the accessing machines configured to use a proxy server that requires authentication?

If you answer both questions with YES: then you found a bug.

The good news is - there is a solution. You can request a fix (free of charge) at a Microsoft support holine and it will be (e-)mailed to you:

KB Artikel 917952: FIX: Error message when you try to install a ClickOnce application that you created in the .NET Framework 2.0 onto a client computer that is configured to use a proxy server: "Proxy authentication required"

with 0 Comments

HOW TO: Debugging ClickOnce Applications

with 0 Comments

Creating thread safe code with C# and .NET

If you have developed traditional Windows Client/Server applications on single-CPU machines for all your life the development of thread-safe code is probably something you did not had to bother.

Here are a few interesting links on how to do it correctly:

Further must-reads? Leave a comment, please!

with 1 Comments

Implement 'On Error Resume Next'-like behavior in .NET 2.0

'On Error Resume Next'-like behavior using Anonymous Delegates in C# 2005

That's just what an good old VB6 developer likes...

static class IgnoreExceptionsSample
{

 
public void Main()
 
{
   
IgnoreExceptions(
delegate { DoSomething(); });
 
}

 
public static void IgnoreExceptions(SimpleDelegate del)
 
{
   
try
   
{
     
del();
   
}
   
catch { }
 
}


}

public delegate void SimpleDelegate();

Important Notice: When an exception is thrown the exception will be ignored, but the delegate will not be executed further (in contrast to VB6 'On Error Resume Next' which continued with the next statement).

Pretty cool, isn't it?

with 0 Comments

Detecting if Running as ClickOnce Application