July 8, 2010, 12:56
Today I found an interesting post about why we should avoid using “AnyCPU” as build type when we are building managed assemblies. The problem simple is that when installing the application and are writing registrie key we need to define if it’s a 32 bit or 64 bit application in the MSI. You can build an EXE as “AnyCPU” and on an x86 windows machine it will run on the 32bit CLR and on an x64 windows machine it will run as a 64bit process.
Christopher Painter gives this example on his blog post to explain the problem:
So let’s start with a simple example. Let’s go back 10 years in time and pretend we are writing an x86 application and x86 installer with no concern for x64. Someone hands you a vb6 EXE and a regfile ( HKLM\SOFTWARE\Company\Product type entries ) and says this is what needs to be deployed. You go off and create an MSI that writes the registry values, deploys the EXE and creates a shortcut. Now let’s come back to present. You take that MSI and throw it on a modern Windows 7 x64 box and it works just fine.
But now let’s pretend that the EXE was a .NET application. If it was compiled as x86 it would behave the same way. But if that application was built at AnyCPU ( the default for all versions of Visual Studio prior to VS2010 ) we are going to land in one of those traps. Here’s why:
MSI is marked as an x86 package so it writes the registry data to the Wow6432Node of the registry so the expected x86 application can find it. While the EXE gets installed to ProgramFiles(x86) it will actually JIT as a 64 bit process. This process will fail to find it’s registry resource at runtime and crash. This is because the .NET BCL Win32.Registry class cares about bitness.
You can find his complete post here
June 15, 2009, 12:26
When installing Dynamics NAV 2009 one of my friend’s rune into this problem:
—————————————————————————–
Microsoft Dynamics NAV 2009 Build 27808
Error Report
RoleTailored client
Microsoft Dynamics NAV 2009 RoleTailored client
Fatal error during installation.
Could not open key: UNKNOWN\MSComDlg.CommonDialog.1\CLSID. Verify that you have sufficient access to that key, or contact your support personnel.
—————————————————————————–
The problem here is that we have a mismatch of .NET. The simplest solution is to install latest version of a .NET and run the installer again.
.NET Framework 3.5 SP1
May 26, 2009, 15:52
Here is the link to the Beta 1 page : http://go.microsoft.com/fwlink/?LinkId=151799
This is page has a ton of Beta 1 resources such as the Download links, ‘How to download’ video, training kit, walkthroughs, forum links, MSDN library links, featured blogs and link to Connect for bugs.
April 6, 2009, 9:26
When I have been looking around on the net about strong naming and signing I have found some confusion about the purpose and the difference between does two methods.
Strong naming
Strong names make names cryptographically strong. When you load banan.dll by its strong name you are saying “load banan.DLL which was signed by XCompany”. The loader verifies that the named dll was signed with the correct key, and if not the loader will refuse to load the dll. This is the only thing that strong naming does (making the name of a dll cryptographically strong). Strong names are not a mechanism for expressing trust decisions. Strong names are just about making a name stronger so that you have a guarantee that the code you are loading at runtime is the code you compiled against. That is the ONLY thing you can safely use a strong name for. Strong name keys go into a “snk” file, which you then typically include with your project.
Certificates signing
Certificates signing are completely different. Certificates form a chain of trust, where a trusted root certificate (Verisign, for example) is installed in every user’s root certificate store. Those trusted root certificates are then used to certify the identities of organizations that issue code signing certificates. This enables the customer to setup trust policies. For example, they can say “I want to trust anything that comes from XCompany”. How will they do that? They first check to see if the dll was signed by an XCompany certificate. But how do they know that the XCompany certificate actually came from XCompany? Because Verisign says so – Verisign signed the XCompany certificate saying “we certify that this dll signing certificate actually came from XCompany”. Why do they trust Verisign? Because Verisign is part of the Microsoft root certificate program. Acceptance into this program means Microsoft trusts these certificate authorities and places their root certificate in the Trusted Root store on Windows machines. That’s the root of the chain of trust. Certificates doesn’t go into strong name key files, they go into the operating system’s certificate store.
March 2, 2009, 16:50
After 1 month of preparation and a weekend that disappeared I have passed my second MCTS exam. I did use the “MCTS Self-Paced Training Kit (Exam 70-526): Microsoft® .NET Framework 2.0 Windows®-Based Client Development” book for my preparation and Measureup’s online test questions. I did also try ActualTest.com’s question that I did borrow from a friend. I found that the questions many times were almost exactly the same (Found some question with exactly the same options). So I can’t recommend ActualTests.com. Measureup did cover all the areas good except the custom control integration to VS design toolbox and properties dialog. Many questions on the real exam were about this functionality that I had not read about in the book or had any questions about in the practice online tests. So for that area I would recommend to read MSDN.
My study strategy was more or less as last MCTS exam. I did read 1 chapter in the book per day/ every second day (15 chapters in total). I also did plan to do the labs in the book but I never got the time for it. Instead I did concentrate on the lesson and chapter review questions plus the summary in the end of every part of the book. The last weekend that totally disappeared from my life, I did go through all lessons and chapter reviews plus summaries. I also did use the Measureup’s web site very heavily. Went through all 150 questions and read all explanations to all questions (this gave me the most). Another good part with the web questions is that it contain link to relevant MSDN sites for more information.
Measureup
MCTS Self-Paced Training Kit (Exam 70-526): Microsoft® .NET Framework 2.0 Windows®-Based Client Development book
February 4, 2009, 8:13
In my earlier blogs (Fun with UIAutomation and calc, Fun with UIAutomation and calc 2 (event handling)) I have been talking about how to user uiautomation in .NET. Now it time to dig down bellow uiautomation and go directly to the source WIN 32 API. I have tried to translate the first calculator project to use win 32 API and accessibility object instead. The first thing that we need to-do is to create DllImport statement for user32.dll used for handling more or less all windows UI and oleacc.dll used for accessing the accessibility object. You will find my complete solution in the end of the blog.
An example of DllImport is EnumChildWindows that gives use the possibility to get all child windows to a specific window.
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr parentHandle, Win32Callback callback, IntPtr lParam);
Continue reading ‘UI automation with accessibility object and win 32 API’ »
January 27, 2009, 12:10
Have you ever wondered how Microsoft does thing inside .NET? Now it’s possible to see the source code by configuring Microsoft reference source server inside visual studio. Just go to ‘Serversetup’ and setup you visual studio 2008 to use symbol files from Microsoft symbol server when you debugging. You can also download the symbol files and use them offline by follow this guide ‘Downloadsetup’.
The symbol files are available for this dll’s in .NET 3.5 SP1.
• mscorlib.dll
• Microsoft.Visualbasic.dll
• system.dll
• System.ComponentModel.DataAnnotations.dll
• system.data.dll
• system.drawing.dll
• System.Web.Abstractions.dll
• system.web.dll
• system.web.extensions.dll
• System.Web.Extensions.Design.dll
• System.Web.DynamicData.dll
• System.Web.DynamicData.Design.dll
• System.Web.Routing.dll
• system.windows.forms.dll
• system.xml.dll
January 12, 2009, 16:03
After 2 month of preparation and a weekend that disappeared I have passed my first MCTS exam. It has been an interesting trip with a lot of new knowledge and frustration when the sample questions don’t make sense (But I did pass the exam pass rate criteria with good marginal). I did use the “MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0 Foundation” book for my preparation and Measureup’s online test questions. The book also contain test question both in the book and one a CD. The questions in the book was really good and helpful both the question on the CD was according to me many times outside of the scope and had no connection to the content in the book or the real exam I did take. Measureup’s questions were the closest ones to the real exam and also the question that I did learn most from.
Continue reading ‘Microsoft .NET Framework - Application Development Foundation’ »
November 23, 2008, 19:23
When I was surfing around today I found this site that contain a bunch of different cheat sheets for .NET. The one that I find really useful was ‘Visual Studio 2005 Built-in Code Snippets‘. So simple have fun with this findings