Archive for the ‘.NET’ Category
Posted by jpluimers on 2012/05/23
Yes. Dorothy. There are people using the ADO .NET Entity Framework with SQL Server 2000 in parallel of moving towards a more modern Microsoft SQL Server version.
Entity Framework is lovely for developing data-centric applications.
By default, Visual Studio 2010 will target SQL Server 2008 as a database. That is fine, but it is kind of invisible it does: there is no property or dialog where you can change this.
What you have to change in order to have the Entity Framework send SQL Server 2000 compatible queries is to:
- Right click your .edmx file
- Choose “Open with”
- Choose the “XML (text) editor”
- Find the ProviderManifestToken attribute
- Change the value (usually from “2008″) into “2000″
- Save the .edmx file
- Build and run your application
A few caveats:
The ProviderManifestToken is usually at this place:
/edmx:Edmx/edmx:Runtime/edmx:StorageModels/Schema/@ProviderManifestToken
Note this is not a full XPath query to it (as you’d have to add the namespaces see also namespaces in XPath), that would be the one below this post’s signature.
From the ProviderManifestToken documentation:
ProviderManifestToken Schema Attribute
ProviderManifestToken is a required attribute of the Schema element in SSDL. This token is used to load the provider manifest for offline scenarios. For more information about ProviderManifestToken attribute, see Schema Element (SSDL).
SqlClient can be used as a data provider for different versions of SQL Server. These versions have different capabilities. For example, SQL Server 2000 does not support varchar(max) and nvarchar(max) types that were introduced with SQL Server 2005.SqlClient produces and accepts the following provider manifest tokens for different versions of SQL Server.
- “2000″ for SQL Server 2000
- “2005″ for SQL Server 2005
- “2008″ for SQL Server 2008
Note: Starting with Visual Studio 2010, the Entity Data Model Tools do not support SQL Server 2000.
Finally, with SQL Server 2000, be sure to set multipleactiveresultsets=false in your connectionstrings to disable MARS (Multiple Active Result Sets) which SQL Server 2000 does not support.
–jeroen
via: SqlClient for the Entity Framework.
Full XPath query would either have you to add namespaces using an XmlNameSpaceManager instance, or use the full namespace urls like here:
//*[namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']/@ProviderManifestToken
or more precisely
/*[local-name()='Edmx' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='Runtime' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='StorageModels' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']/*[local-name()='Schema' and namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']/@ProviderManifestToken
or on multiple lines:
[sourececode language='text']
/*[local-name()='Edmx' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='Runtime' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='StorageModels' and namespace-uri()='http://schemas.microsoft.com/ado/2008/10/edmx']
/*[local-name()='Schema' and namespace-uri()='http://schemas.microsoft.com/ado/2009/02/edm/ssdl']
/@ProviderManifestToken
[/sourcecode]
for this .edmx file (hoping that WordPress doesn’t mess with the xml as it usually does).
[sourececode language='xml']
[/sourcecode]
Yup, it did it again; please see this file for the XML.
–EOM–
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, EF Entity Framework, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2012/05/17
When trying to dissect .NET 1.1 web services from their .asmx and WSDL, you need some tooling.
You’d think the WCF Test Client works, but it only partially generates the calls; it gets the methods OK, but not the parameters.
Importing the .NET WebService in Visual Studio is another option, but not for a “quick play around with the calls”.
For that, Soap UI seems a good option.
If you know better tools, please let me know in the comments.
It works, and when you get it to work it is dead slow (it keeps one core running at 50%).
Getting it to work gives many people this kind of error message: Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, Development, SOAP/WebServices, Software Development | Leave a Comment »
Posted by jpluimers on 2012/05/16
As a Delphi user, I’m missing the “Reverse Assignment” feature in the Visual Studio version of CodeRush.
Since CodeRush is very extendable (Mark is still explaining to people how the idea for that came from Delphi Packages back in the mid 90s), you can add this one yourself, as the a answer to this DevExpress support issue shows:
Q:
Is there a quick way to reverse the assignment in CodeRush? For example:
FROM:
Field[“test1”] = edTest1.Value;
Field[“test2”] = edTest2.Value;
TO:
edTest1.Value = Field[“test1”];
edTest2.Value = Field[“test2”];
I know Delphi had this capability in its refactoring, does CodeRush for Visual Studio?
Thanks
Daniel Schipper
Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/05/15
(Thanks to a “Missed Post” problem on WordPress.com, this one didn’t get posted on the scheduled date. Sorry for any inconvenience)
One of the next steps in the automated build process I’m setting up is increasing AssemblyVersion values after succesful builds.
It is is in a CCnet / TFS2010 / VS2010 environment.
Some links:
–jeroen
via: change assemblyversion during checkin ccnet – Google Search.
Like this:
Be the first to like this post.
Posted in .NET, C#, Continuous Integration, CruiseControl.net, Development, Software Development, Source Code Management, TFS (Team Foundation System) | Leave a Comment »
Posted by jpluimers on 2012/05/15
When in a DTAP environment, you cannot always have complete clean boundaries. Issues in production don’t reproduce in acceptance, you cannot develop in production, etc.
So sometimes you have to simulate or connect to Test or Acceptance Database Servers from a Develop workstation.
There it can get hairy to keep track of which applications connect to which database server.
That’s where the below batch file comes in handy: it scans your systems on connections to common TCP ports used by SQL server, then for each connection give you some process details (or – if you add a commandline parameter – all details that TLINK can get).
The batch file uses the built in tools tasklist, netstat, find and sc (the latter to show information on the local running SQL Services).
It also uses TLIST, which can be a bit awkward to get.
Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, Batch-Files, Database Development, Development, Scripting, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »
Posted by jpluimers on 2012/05/10
To bad that Greg Beechs Blog only has “42 Entries” as those entries (from the start of 2006 till the end of 2009) are well worth reading on various .NET related topics.
–jeroen
via Greg Beechs Blog | Greg Beechs Website.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/26
Some very interesting tips from game development that apply juts as well to general software development.
On code health:
Now I always try to dig right down to the root cause of a bug, even if a simple, and seemingly safe, patch is available. I want my code to be healthy. If you go to the doctor and tell him “it hurts when I do this,” then you expect him to find out why it hurts, and to fix that.
Though tools like SourceMonitor can help you track your code health, the best tool is between your ears.
–jeroen
via: Dodgy Coder: Coding tricks of game developers.
Like this:
One blogger likes this post.
Posted in .NET, Batch-Files, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi x64, Delphi XE2, Development, JavaScript/ECMAScript, PHP, PowerShell, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2012/04/24
While transitioning from SQL Server 2000 to 2008, I recently had the “A severe error occurred on the current command. The results, if any, should be discarded.” occurring on SQL Server 2000 in the form as shown at the bottom of this message.
Many of the search results point you into the area of atabase corruption, or in using NVARCAR parameters with SQL Server 2000 or SQL Server 2005 (the app didn’t use NVARCAR, nor did it use large VARCHAR parameters).
The cool thing on the SQL Server Forums – System.Data.SqlClient.SqlException: A severe error occurred on the current command post was that it summed up causes, and asked for more:
Posted - 06/17/2004 : 15:05:20
Rashid writes “Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (http://support.microsoft.com/default.aspx?scid=kb;en-us;827366) these errors happen due to following resons
- You use a SqlClient class in a Finalize method or in a C# destructor.
- You do not specify an explicit SQLDbType enumeration when you create a SqlParameter object. When you do not specify an explicit SQLDbType, the Microsoft .NET Framework Data Provider for SQL Server (SqlClient) tries to select the correct SQLDbType based on the data that is passed. SqlClient is not successful.
- The size of the parameter that you explicitly specify in the .NET Framework code is more than the maximum size that you can use for the data type in Microsoft SQL Server.
None of these are true in my case. Are there any other reasons that can cause these problems..
There is one more: sending huge SQL Statements to your SQL Server is always a bad idea and gives this error too. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Database Development, Development, Software Development, SQL Server, SQL Server 2000, SQL Server 2008 R2 | Leave a Comment »
Posted by jpluimers on 2012/04/18
Everytime I get a warning like
Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by ConfigurationManager.AppSettings'
it reminds me I should have written a blog post about it, as the solution is a tiny bit more than just replacing System.Configuration.ConfigurationSettings.AppSettings by System.Configuration.ConfigurationManager.AppSettings.
Scott Gate wrote a nice post on his old blog about this (his new blog is awesome, he really should import his old posts into his new blog) that explains how to solve this well, so below is an elaboration on the how of the change, a tiny trick and a short series of steps to resolve this warning.
First of all, the above message means you are touching code that has been written in the .NET 1.x era, and the maintaining people (you! <g>) have been too lazy to solve the warning. That is bad, as your code should compile without warnings, and preferably without hints too. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/11
a BNF grammer for C# v2 has moved from www.devincook.com/GOLDParser/grammars/index.htm to goldparser.org/grammars.
It is mostly complete, and a good learning experience to both BNF and the C# syntax.
ANTLR grammers are available for C# 2, and a partially for C# 4.
–jeroen
via: c# 4.0 – C# grammar in BNF or EBNF Parser generator for F# – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/06
If you like .NET and scripting, then PowerShell and the PowerShell Community Extensions is what you should try:
PowerShell – The full power of .NET, WMI and COM all from a command line. PowerShell has a steep learning curve, much like the tango, but oh, my, when you really start dancing…woof. I also use PowerShell Prompt Here. Its built into Windows 7, by the way.
- I also recommend after installing PowerShell that you immediately go get PowerTab to enable amazing “ANSI-art” style command-line tab completion.
- Next, go get the PowerShell Community Extensions to add dozens of useful commands to PowerShell.
- Want a more advanced GUI for PowerShell? Get the free PowerGUI.
Thanks Scott for summarizing
–jeroen
via: Scott Hanselmans 2011 Ultimate Developer and Power Users Tool List for Windows – Scott Hanselman.
Like this:
Be the first to like this post.
Posted in .NET, Development, Power User, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/05
Finally, Google allows searching for C# and returns meaningful results (previously they returned the same results as searching for C).
They improved a bunch of other special characters as well.
–jeroen
via:
Search quality highlights: 50 changes for March – Inside Search.
Like this:
Be the first to like this post.
Posted in .NET, C#, Development, Google, GoogleSearch, Power User, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/05

O'Reilly book "Unicode Explained: Internationalize Documents, Programs, and Web Sites"
Withe the growing integration between systems, and the mismatch between those that support Unicode and that do not, I find that a lot of organisations lack basic Unicode knowledge.
So lets put down a few things, that helps as a primer and gets some confusion out of the way.
Please read the article on Unicode by Joel on Software, and the book Unicode Explained. The book is from 1996, and still very valid.
Unicode
Unicode started in the late 80s of last century as a 16-bit character model.
Somehow lots of people still thing Unicode is a 16-bit double-byte character set. It is not. It uses a variable width encoding for storage.
All encodings except the 32-bit ones are variable width. The UTF-16 encoding is a variable width encoding where each code point (not character!, see below why) takes one or more 16-bit words.
This is because – as of Unicode version 2.0 in 1996 – a surrogate character mechanism was introduced to be able to have more than 64k code points.
The architecture of Unicode is completely different than traditional single-byte character sets or double-byte character sets.
In Unicode, there is a distinction between code points (the mapping of the character to an actual IDs), storage/encoding (in Windows now uses UTF-16LE which includes the past used UCS-2) and leaves visual representation (glyphs/renderings) to fonts.
Unicode has over a million code points, logically divided into 17 planes, of which the Basic Multi-lingual Plane has code points that can be encoded into one 16-bit word.
There is no font that can display all Unicode code points. By original aim, the first 256 Unicode code points are identical to the ISO 8859-1 character set (which is Windows-29591, not Windows-1252!) for which most fonts can display most characters.

By now, you probably grasp that Unicode is not an easy thing to get right. And that can be hard, hence people love and hate Unicode at the same time. Maybe I should get the T-Shirt
.
One thing that complexes things, is that Unicode allows for both composite characters and ready made composites. This is one form where different sequences can be equivalent, so there can be Unicode equivalence for which you need some knowledge on Unicode Normalization (be sure to read this StackOverflow question and this article by Michael Kaplan on Unicode Normalization).
There are many Unicode encodings, of which UTF-8 and UTF-16 are the most widely used (and are variable length). UTF-32 is fixed length. All 16-bit and 32-bit encodings can have big-endian and little-endian storage and can use a Byte Order Mark (BOM) to indicate their endinaness. Not all software uses BOMs, and there are BOMs for UTF-8 and other encodings as well (for UTF-8 it is not recommended to include a BOM).
When only parts your development environment supports Unicode strings, you need to be aware of which do and which don’t. For any interface boundary between those, you need to be aware of potential data loss, and need to decide how to cope with that.
For instance, does your database use Unicode or not for character storage? (For Microsoft SQL Server: do you use CHAR/VARCHAR or NCHAR/NVARCHAR; you should aim for NVARCHAR, yes you really should, do not use text, ntext and image). What do you do while transferring Unicode and non-Unicode text to it? Ask the same questions for Web Services, configuration files, binary storage, message queueing and various other interfaces to the outside world.
The Windows API is almost exclusively Unicode (see this StackOverflow question for more details)
Delphi and Unicode
Let’s focus a bit on Delphi now, as that the migration towards Unicode at clients raised a few questions over the last couple of months.
One of the key questions is why there are no conversion tools that help you migrate your existing source code to fully embrace Unicode.
The short answer is: because you can’t automate the detection of intent in your codebase.
The longer answer starts with that there are tools that detect parts of your Delphi source that potentially has problems: the compiler hints, warnings and errors that brings your attention to spots that are fishy, are likely to fail, or are plain wrong.
Delphi uses the standard Windows storage format for Unicode text: UTF-16LE.
Next to that, Delphi supports conversion to and from UTF-8 en UTF-32 (in their various forms endianness).
External storage of text is best done as UTF-8 because it doesn’t have endianness, and because of easier exchange of text in ISO-8859-1.
Marco Cantu wrote a very nice whitepaper about Delphi and Unicode, and I did a Delphi Unicode talk at CodeRage 4 and posted a lot of Delphi Unicode links at StackOverflow.
A few extra notes on Delphi and Unicode:
With Delphi string types, stick to the UnicodeString (default string as of Delphi 2009) and AnsiString (default string until Delphi 2007) as their memory management is done by Delphi. WideString management is done by COM, so only use that when you really need to. Also avoid ShortString.
For any interfaces to the external world, you need to decide which ones to keep to generic string, Char, PChar and which ones to fix to AnsiChar/PAnsiChar/AnsiString(+ accompanying codepage) or fix at UnicodeChar/PUnicodeChar/UnicodeString.
Of course remnants from the past will catch up with you: if you have Technical Debt on the past where characters were bytes, and you abused Char/PChar/array-of-char/etc you need to fix that, and use the Byte/PByte/TByteArray/PByteArray. It can be costly to pay the accrued debt on that.
–jeroen
PS:
Like this:
Be the first to like this post.
Posted in .NET, C#, Delphi, Development, EBCDIC, Encoding, ISO-8859, Software Development, Unicode, UTF-8 | 2 Comments »
Posted by jpluimers on 2012/04/04

Thanks to Randy Glasbergen for the debt image
I love this quote from Jeff Attwood on technical debt in 2009:
periodically pay down your technical debt
and the Computer Weekely article about half a year ago:
Short-term speed may come at the price of long-term delays and cost.
Lately, I find that I need to explain Debt in relation to IT and Software Development more and more often.
We now all know what happens with the financial system when we let debt get out of control.
The same holds for your IT and Software Development.
Debts get introduced by not “playing by the rules”. The quotes are there because you can not always play nicely, and the rules are not always clear or known.
Lets give a few examples of rules that – from experience at clients – are more often than not neglected. The examples are based on Windows, but could just as easily be Mac OS X, Unix, OS/400 or anything else.
- Make sure you use a recent Windows version
I often see companies lagging more than one version behind (i.e. still use Windows XP or SQL Server 2000). That’s too far.
- Don’t run your users with too many privileges (and certainly not as Administrators)
Especially running as Administrator will get you in trouble with User Account Control (UAC) in Windows Vista and up.
- Using directories like C:\TEMP is a no-no.
This should be a no-brainer, but truckloads of in-company software still thinks it can write everywhere.
I know C:\TEMP used to be the Temporary Folder some 20 years ago.
But that was then, and this is now: Use the %TEMP% environment variable or GetTempPath function (even better: the GetTempFileName function or the .NET Path.GetTempFileName function).
More in general for known folders, use CSIDL or KNOWNFOLDERID whenever possible. Your favourite development tool usually has a library functions for that, for instance the .NET System.Environment.GetFolderPath function.
These few were examples ranged from technically very broad to specific. There are more, but these will give you a rough idea how wide the field of debt can be. Even debt outside the realm of Technical Debt can turn out to be really expensive.
Every time you postpone or skip a Windows version, you collect some debt in the hope (often wrongfully called expectation) that you earn more on the money/resource you just didn’t invest and putting that money/resource to use otherwise. The same holds for any other kind of debt.
The main problem with debt is not the total of the debt, it is the interest rate that makes the accrued debt grows faster than most people and organizations realize.
This is actually one of the main causes of the current world wide financial crisis, the same holds for many IT debts.
And for all kinds of debts, you often don’t know how high the interest rate will be, so the accrued value can be way beyond what you expect.
I’ve regularly seen projects collecting so much debt, that migration costs raised to thousands of hours because of it, resulting into management taking another very bad decision: rewriting the stuff from scratch. Don’t do that: Joel on Software excellently describes what happens when you do that.
What to do about it?
You might say “don’t collect debt”, but you can’t always avoid debt.
So you need to build periods where you pay off accrued debt. And you need to do that regularly, in order to avoid the interest pitfall.
This does not limit itself to software development (though that’s what I normally focus at). It covers a wide range of IT topics.
Sometimes, you can even pay your debt in advance. For instance, I was among the first to switch from Windows XP to the x64 of Windows Vista. I knew it would cause pain, but it immediately payed back by being able to use much more memory, and run more Virtual Machines at the same time. That made me more flexible and productive.
–jeroen
via: Coding Horror: Paying Down Your Technical Debt.
Like this:
Be the first to like this post.
Posted in *nix, .NET, Delphi, Development, Opinions, Power User, Software Development, Windows, Windows 7, Windows 8, Windows Vista, Windows XP | 5 Comments »
Posted by jpluimers on 2012/04/03
Quite a few projects have one or more classes with with a bunch of public const string or public static readonly string values. Use const when things are really constant (like registry configuration keys), use static readonly when – upon change – I do not want to recompile dependent assemblies. Many people recommend static readonly over const.
Having members in stead of string literals scattered all over the place allows you to do compile timing checking, which I’m a big fan of as in the age of things getting more and more dynamic, you need to have as many sanity checks as possible.
One of the checks is to verify these const members and their values. Sometimes you need the list of members, sometimes the list of values, and sometimes each member value should be the same as the member name.
The listing below shows the code I came up with.
It works with code like this, and those can have more code and other fields (non string, non public) in them as well:
namespace bo.Literals
{
public class FooBarPublicStringConstants
{
public const string Foo = "Foo";
public const string Bar = "Bar";
}
public class FooBarPublicStaticReadOnlyStringFields
{
public static readonly string Foo = "Foo";
public static readonly string Bar = "Bar";
}
}
I started out with this code, but that is limited to classes only having public const fields. Not flexible enough. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/29
August 2011, Microsoft re-issued KB2251481. They should not have done that, because if you have the original KB2251481 installed (also known as KB2251481.T369_32ToU865_32) you need to go through the hoopla below to uninstall it.
In stead, they should have released a new version that automatically uninstalls a previously installed one, then installs itself.
It is not the first patch that Microsoft did wrong, but this one is the “Microsoft Visual Studio 2005 Service Pack 1 XML Editor Security Update”. Every now and then I come across it when doing work on some archived virtual machines that contain Visual Studio 2005 (which I used a lot in the past, and occasionally still use for doing some maintenance work for clients that long ago ditched stuff they thought they’d never need to use again).
The really stupid thing is the error message you get when it cannot get installed: John Doe user will never find out why it failed, let alone figure out how to get it install properly.
This is the message you will see:
[Automatic Updates]
Some updates could not be installed
The following updates were note installed:
Security Update for Microsoft Visual Studio 2005 Service Pack 1 XML Editor (KB2251481)
[Close]
The message doesn’t even include that it is trying to install the August 2011 version (hinting that there might be an earlier version you need to uninstall). Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, Development, Software Development, Visual Studio 2005, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/03/28
Duh, I always thought @ could only be used for strings.
Not so: just like with the & in Delphi, you can use @ for identifiers too.
The prefix “@” enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier.
–jeroen
via: naming – What’s the use/meaning of the @ character in variable names in C#? – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/27
So I won’t forget: a GetName method returning the name of a parameter, local or field.
Tags: C#, reflection, IL parsing, argument name, anonymous type, generic type cache, generic type caching.
–jeroen
via: reflection – C# – Resolving a parameter name at runtime – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | 1 Comment »
Posted by jpluimers on 2012/03/21
More than a year ago, I wrote about enabling PowerShell to run unsigned scripts.
The solution there uses the Set-ExecutionPolicy cmdlet, but only works for administrators. As of PowerShell 2.0, there is more fine grained control for the Set-ExecutionPolicy cmdlet, and an updated Set-ExecutionPolicy cmdlet topic which I overlooked.
The solution below shows what happens when the current user is not an administrator, and works around it by applying it only for the current user.
error message:
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
Sure enough I don’t have permission to this registry key.
I checked with our admin to ensure this wasn’t set in group policy before I started fiddling around. Found out that there is another setting that is user specific that can be set with
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
This will allow the current user to run unsigned scripts he wrote himself, but still require remote (for instance downloaded) scripts to be signed.
Note it is easy to strip the “remote” flag of a downloaded script: NTFS keeps this flag in the Zone:Identifier NTFS alternate data stream.
Only do that for scripts you trust.
–jeroen
via: Absoblogginlutely! » Enabling powershell to run scripts with registry permissions..
Like this:
Be the first to like this post.
Posted in .NET, Development, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/20
When moving the Microsoft Scripting Runtime interop code from .NET 1.x to 4.x, I got these errors:
Error1: The type 'Scripting.FileSystemObjectClass' has no constructors defined
Error21: Interop type 'Scripting.FileSystemObjectClass' cannot be embedded. Use the applicable interface instead.
Though the first answers on the question seem to adequately resolve the problem, they merely cure the symptom: turning off the embedding of the PIA (Primary Interop Assembly).
The below answer by Michael Gustus (which only has a few votes, so please vote it up) actually explains what is going on, and solves the cause:
In most cases this error is the result of code which tries to instantiate a COM object e.g. here piece of code starting up Excel:
Excel.ApplicationClass xlapp = new Excel.ApplicationClass();
Typically, in .Net 4 you just need to remove the ‘Class’ suffix and compile the code:
Excel.Application xlapp = new Excel.Application();
MSDN explanation here.
Hence I like the comment by Tyrsius on this answer as well:
This was more useful than the marked answer, as I needed the functionality of the embedded Interop. This solved both problems, thank you!
The above answer tells you to not use the class type, but the interface type, just like the error states. And the answer implicitly tells you the class type is ApplicatoinClass, and the interface is Application.
These are the declarations for the PIA interface: Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 4.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/03/13
Sometimes when creating new Team work items in Visual Studio 2010 connected to Team Foundation System 2010, you get a sub menu like this:

“New Work Item menu still loading… (try again in a moment)”
There are not many results in the new work item menu still loading “try again in a moment” site:microsoft.com query, but luckily the first one shows a similar issue in Visual Studio 2005 with Team Foundation System 2005: the “Add Work Item menu still loading… (try again in a moment)”.
The solution is also very simple:
- Quit Visual Studio 2010
- Delete this registry key
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\WorkItemTracking\TeamMenu\AddWorkItemMru
- Start Visual Studio 2010
- Retry (can take more than a minute, but it usually works)
The only difference between the Visual Studio 2010 (version 10.0) and Visual Studio 2005 (version 8.0) is the version number:
- HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\WorkItemTracking\TeamMenu\AddWorkItemMru
Not sure if this can fail in Visual Studio 2008 too, but if it does, just apply this fix with version number to 9.0, and if it happens with the Visual Studio 11 developer preview, change the version number to 11.0.
–jeroen
via: Add Work Item menu still loading….
Like this:
Be the first to like this post.
Posted in .NET, Development, Software Development, Visual Studio 2005, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/03/12
Handy when working with Microsoft Surface: install your development environment on a separate VHD that you can boot as your physical machine (Microsoft Surface SDK does not like being run in a Virtual Machine):
If you accept the constraints described above, I propose the following procedure, which I think is the easiest way to install Windows 7 on a virtual disk in multi-boot
Note: Within the VHD you can still access all the files on your physical HD.
–jeroen
via: How to install Windows 7 on a virtual hard disk (VHD) in 10 steps – Guides & Tutorials.
Like this:
Be the first to like this post.
Posted in .NET, C#, Development, Microsoft Surface, Microsoft Surface on Windows 7, Power User, Software Development, Windows, Windows 7, WPF, XNA | 1 Comment »
Posted by jpluimers on 2012/03/08
This use case drove me nuts in Visual Studio 2010 for a while, but can be solved.
Use cases:
double click on a word to select it
- press Ctrl-C to copy the selected text
- result is either of these two dialogs:
---------------------------
Microsoft Visual Studio
---------------------------
Cannot navigate to definition.
---------------------------
OK
---------------------------
or
---------------------------
Microsoft Visual Studio
---------------------------
Cannot navigate to definition. The cursor is not on a symbol.
---------------------------
OK
---------------------------
The reason is that Visual Studio 2010 still thinks I am clicking the identifier (which I’m not, I just released the mouse button) while pressing the Ctrl key. Read the rest of this entry »
Like this:
Be the first to like this post.
Posted in .NET, Delphi, Development, Software Development, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/03/07
It seems I’m not the ony one who watches what Eric Lippert writes closely.
Eric works at the C# team at Microsoft (since 1996, which is about the time Anders Hejlsberg joined Microsoft).
Unlike Anders, Eric is much more visible. I regularly read his blog, and watch his StackOverflow.com contributions (RSS feed) on a regular base.
Recently, he posted a awesome comment “Nullable is nothing but magic” on a the question “C# – Why does the == operator work for Nullable when == is not defined?“, together with a very concise answer explaining that in C# most operators are ‘lifted to nullable’.
Note his tiny – but important – mention that for == VB.net behaves different than C#.
Note that Eric is very productive, he usually contributes to StackOverflow.com multiple times a day, sometimes with material that (at least for me <g>) need a while before I really get the point.
Recommended reading
–jeroen
via: c# – Why does the == operator work for Nullable when == is not defined? – Stack Overflow.
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, VB.NET | Leave a Comment »
Posted by jpluimers on 2012/03/06
A short while ago a paper got published on PRESENT: An Ultra-Lightweight Block Cipher by Andrey Bogdanov et al becoming ISO standard 29192-2:2012.
Is there anyone that has a C#, Delphi or FreePascal implementation with unit tests?
–jeroen
Like this:
Be the first to like this post.
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Software Development | 12 Comments »
Posted by jpluimers on 2012/03/02
Hopefully they will add Visual Studio 2011 ISOs (no, not the current ones that still download the prerequisites in the background) like they did with the Windows 8 Consumer Preview ISOs:
English
| 64-bit (x64) |
Download (3.3 GB) |
Sha 1 hash — 1288519C5035BCAC83CBFA23A33038CCF5522749 |
| 32-bit (x86) |
Download (2.5 GB) |
Sha 1 hash — E91ED665B01A46F4344C36D9D88C8BF78E9A1B39 |
|
Product Key |
DNJXJ-7XBW8-2378T-X22TX-BKG7J |
–jeroen
via: Windows 8 Consumer Preview ISO formats.
Like this:
Be the first to like this post.
Posted in .NET, Development, Power User, Software Development, Visual Studio 11, Visual Studio and tools, Windows, Windows 8 | 2 Comments »
Posted by jpluimers on 2012/02/29
(Note the WordPress bug: you cannot have <Default> in a topic title, but having it in the text is fine, hence the [Default] in the title).
When porting some projects from .NET 1.x to .NET 4.x, I got these two errors:
Error 17 Type 'MyProject.My.MySettings' is not defined.
Error 18 'MyProject' is not a member of '<Default>'.
Both errors in the file ...\My Project\Settings.Designer.vb relative to the MyProject.vbproj file.
This was not the result of something like this Visual Studio 2005 bug, but of how the designer generated files are not being regenerated when you change the root namespace only in the MyProject.vbproj file, not through the IDE.
Steps to reproduce:
- Create a MyProject class library in VB.NET
- In the MyProject.vbproj, change the RootNameSpace into MyNameSpace.MyProject.vbproj
- Build
Lesson learned: when using text compare tools, some .vbproj changes should be propagated through the IDE, not through your favourite text compare tool.
When you change it in the IDE, it regenerates the *.Designer.vb files to reflect the changed namespace.
The solution is simple, in the IDE follow these steps:
- In the Project Options change the RootNameSpace to a dummy
- Build your project
- Chante the RootNameSpace to what you want
- Build your project
–jeroen
via: type “my.mysettings” “is not defined.” – Google Search.
Like this:
Be the first to like this post.
Posted in .NET, Development, Software Development, VB.NET | Leave a Comment »