Archive

Posts Tagged ‘Visual Studio 2010’

Another run-time hiccup

January 17th, 2012 No comments

I’m running a 64-bit version of Win7. There’s a little niggle when you’re trying to compile x86 apps. It’s a long story. Some people say to run everything in a ‘new’ debug configuration named x86. I found a solution that cuts to the real issue. You need to update your system to know it should target to x86 platforms.

Solution

Run the following command from a command prompt while running as administrator.

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe setwow

Reference:

Here is the reference where I found this info:

http://social.msdn.microsoft.com/forums/en-US/phoenix/thread/9a43e9a1-a744-4a1a-bb34-3604254c126b/

As you can see the moderator presented the solution, so it’s basically a Microsfot blessed solution.

Enjoy!

MSB3061 – Resolution

January 17th, 2012 No comments

Today, I’ve been having problems with Visual Studio. I keep getting these weird “MSB3061″ errors. The solution for me was t oclose Visual Studio and do the right-click “Run As Administrator”. The problem went away after that. I suppose I should do a clean then try to launch VS under my normal user rights.

Easy work around… Maybe it will work for you.

No mapping between account names and security IDs was done

November 12th, 2011 No comments

Today, I’ve been working with my build team to get setup packages built for our current project.  I have to admit, I’ve never really had to deal with installers before.  I’ve either worked on small packages where I could use a click-once deployment or I’ve been working on really big projects with a dedicated build team.  I’d hand off my code by checking it into source control.  My current project is a bit different because I’m doing the architecture, leading the day-to-day development, and doing all of the hiring/firing bits too AKA management. 

 

Anyway…  One issue we had today was this:

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: No mapping between account names and security IDs was done

 

The issue is that the serviceProcessInstaller1 (default name) is using a user account during the install. 

Oops.

Here is a quick overview of Service Accounts from the Microsoft site:

Each service executes in the security context of a user account. The user name and password of an account are specified by the CreateService function at the time the service is installed. The user name and password can be changed by using the ChangeServiceConfig function. You can use the QueryServiceConfig function to get the user name (but not the password) associated with a service object. The service control manager (SCM) automatically loads the user profile.

When starting a service, the SCM logs on to the account associated with the service. If the log on is successful, the system produces an access token and attaches it to the new service process. This token identifies the service process in all subsequent interactions with securable objects (objects that have a security descriptor associated with them). For example, if the service tries to open a handle to a pipe, the system compares the service’s access token to the pipe’s security descriptor before granting access.

The SCM does not maintain the passwords of service user accounts. If a password is expired, the logon fails and the service fails to start. The system administrator who assigns accounts to services can create accounts with passwords that never expire. The administrator can also manage accounts with passwords that expire by using a service configuration program to periodically change the passwords.

If a service needs to recognize another service before sharing its information, the second service can either use the same account as the first service, or it can run in an account belonging to an alias that is recognized by the first service. Services that need to run in a distributed manner across the network should run in domain-wide accounts.

 

So?

You need to set the user account to fit your needs.  You can do it through code as discussed above or you can do it inside the ProjectInstaller.cs [Design] screen in Visual Studio. 

Open the design view, then click once on “serviceProcessInstaller1”.   Next right-click and select properties.   

ServiceInstallerAccountUser

There are 4 options for which account you want to use.

ServiceInstallerUserOptions

User (default)

Since the this is the default and the existing setup doesn’t work, this might not be the best option for you. 

Why is this a problem?  This account selection loads the service as the current user which may or may not be what you want.  When you are running/installing the service on your dev machine everything installs as admin, because that’s the context you are running in.  Which is fine.  But when you try to install the service via an install package on a different computer your runtime security context might be different. 

LocalService

From Microsoft

 

The LocalService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and presents anonymous credentials on the network.

 

 

NetworkService

From Microsoft

 

The NetworkService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and acts as the computer on the network.

 

 

LocalSystem

From Microsoft

 

The LocalSystem account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has extensive privileges on the local computer, and acts as the computer on the network. Its token includes the NT AUTHORITY\SYSTEM and BUILTIN\Administrators SIDs; these accounts have access to most system objects. The name of the account in all locales is .\LocalSystem. The name, LocalSystem or ComputerName\LocalSystem can also be used. This account does not have a password. If you specify the LocalSystem account in a call to the CreateService or ChangeServiceConfig function, any password information you provide is ignored.

 

 

For my project: we’re moving data between servers with WCF, running an MSMQ service, and reading/writing files from the local file system.  We picked “LocalSystem” for our account.

 

ServiceInstallerAccountLocalSystem

 

Problem solved.

 

References:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686005(v=VS.85).aspx

Architecture Tooling Guidance v2.1 is Available

May 4th, 2011 No comments

Blog entry by Willy-P. Schaub

Visual Studio 2010 Architecture Tooling Guidance on CodePlex

A quick glance at the downloads shows guidance for new projects as well as retooling existing projects.  That sounds pretty cool to me.  I’ve got at least 4 different projects that have reached road blocks in refactoring because I didn’t plan well enough.  I planned too grand a solution or started out with too small of a vision.  How much is just enough? 

Alas, I do struggle with seeing that which is right under my nose and correctly planning for the future.

What’s that Fred Brooks quote?

Good judgment comes from experience and experience comes from bad judgment.

Live and learn.

Build Error: Library project file cannot specify ApplicationDefinition element.

April 11th, 2011 No comments

Here’s how I managed to get there. 

I merged 2 assemblies.  (Both contained xaml files.) 

My steps to get into this minor mess.

  1. Dragged the files from the smaller assembly into the larger one. 
  2. Renamed the larger assembly. 
  3. Updated the project properties to match the new name/function of the assembly through the project properties screen.   
  4. Ran the ‘Adjust Namespace’ tool in Resharper across the entire project. 
  5. Build
  6. BOOOOM!!!
    The first error listed is:

Library project file cannot specify ApplicationDefinition element.

Does that sound familiar?

The problem is the ‘Build Action’ on the .xaml file properties.  When I moved the xaml files the build action was changed to “ApplicationDefinition”.  These settings fix it:

Build Action –> Page

Copy to Output Directory –> Do not copy

Custom Tool –> MSBuild:Compile

Go through all of your xaml files.  Make sure they are all using these settings. 

Worked for me. 

 

Reference:

Buried in this article is a pointer by Marco Zhou that helped me figure it out.   

Parallel Processing

March 24th, 2011 No comments

image

I noticed this little change to my upgrade workflow this morning.  Visual Studio 2010 SP1 actually starts the upgrade BEFORE all of the modules have been downloaded.  Nice. 

Parallel processing at it’s best.  Any time the application of technology becomes a non-event, I’m happy.  Apps should “just work” without the user having to think too much about the implementation details.  The thought process should be on the content, not the delivery method. 

ObservableObject: More goodness

March 2nd, 2011 No comments

I’ve been working my way through Karl Shiffett’s MVVM in a box training module.  He has a neat little helper for the ObservableObject that adds a check to make sure you’ve wired everything up when using string-based property changed handlers.  

 

Here is the new method:

 

/// <summary>
/// Warns the developer if this Object does not have a public property with 
/// the specified name. This method does not exist in a Release build.
/// </summary>
[Conditional("DEBUG")]
[DebuggerStepThrough]
public void VerifyPropertyName(String propertyName)
{
  // verify that the property name matches a real,
  // public, instance property on this Object.
  if ( TypeDescriptor.GetProperties(this)[propertyName] == null )
    Debug.Fail("Invalid property name: " + propertyName);
}

 

Here’s the Karl version of the entire class:

 

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;

//Event Design: http://msdn.microsoft.com/en-us/library/ms229011.aspx

namespace XamDockManager.Common.Infrastructure
{

    [Serializable]
    public abstract class ObservableObject : INotifyPropertyChanged
    {

        [field: NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(String propertyName)
        {
            VerifyPropertyName(propertyName);
            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }

        protected void OnPropertyChanged<T>(Expression<Func<T>> propertyExpresssion)
        {
            var propertyName = PropertySupport.ExtractPropertyName(propertyExpresssion);
            OnPropertyChanged(propertyName);
        }

        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            var handler = PropertyChanged;
            if ( handler != null )
            {
                handler(this, e);
            }
        }

        /// <summary>
        /// Warns the developer if this Object does not have a public property with
        /// the specified name. This method does not exist in a Release build.
        /// </summary>
        [Conditional("DEBUG")]
        [DebuggerStepThrough]
        public void VerifyPropertyName(String propertyName)
        {
            // verify that the property name matches a real,
            // public, instance property on this Object.
            if ( TypeDescriptor.GetProperties(this)[propertyName] == null )
            {
                Debug.Fail("Invalid property name: " + propertyName);
            }
        }
    }
}

 

You might notice, there another external requirement, PropertySupport.

Here is that class as well:

public static class PropertySupport
{
    public static String ExtractPropertyName<T>(Expression<Func<T>> propertyExpresssion)
    {
        if ( propertyExpresssion == null )
        {
            throw new ArgumentNullException("propertyExpresssion");
        }

        var memberExpression = propertyExpresssion.Body as MemberExpression;
        if ( memberExpression == null )
        {
            throw new ArgumentException("The expression is not a member access expression.", "propertyExpresssion");
        }

        var property = memberExpression.Member as PropertyInfo;
        if ( property == null )
        {
            throw new ArgumentException("The member access expression does not access a property.", "propertyExpresssion");
        }

        var getMethod = property.GetGetMethod(true);
        if ( getMethod.IsStatic )
        {
            throw new ArgumentException("The referenced property is a static property.", "propertyExpresssion");
        }

        return memberExpression.Member.Name;
    }
}

 

If you’d like more info on MVVM for WPF, check out Karl’s In the Box – MVVM Training for VS 2010.  You can get it for free.

http://karlshifflett.wordpress.com/2010/11/07/in-the-box-ndash-mvvm-training/

http://visualstudiogallery.msdn.microsoft.com/3ab5f02f-0c54-453c-b437-8e8d57eb9942?SRC=VSIDE

VS 2010 Pro FREE!!!

June 17th, 2010 No comments

Attend the Portland Visual Studio 2010 Community Launch tonight…

The first 200 people in the door will receive free, preauthorized access
for Microsoft® WebsiteSpark™
which includes Visual Studio 2010 Professional
and other valuable developer resources!

RSVP now!

Power Tools, Productivity & Swag

June 10th, 2010 No comments

Yesterday, ScottGu blogged about new VS 2010 Productivity Power Tool Extensions.  Having wholly bought into the power of the Extension Manager, I think this add-on is another must-have for VS 2010. 

If you already know you want it, you can download the extension here.

Enjoy!

PS: Don’t forget to RSVP for the Portland Visual Studio 2010 Community Launch event at Fiserv on June 17th.  The first 200 people in the door will receive free, preauthorized access for Microsoft WebSpark.  More info at the PADNUG website.  Here is the link to RSVP directly.

MVC App Conversion.

May 23rd, 2010 No comments

I’ve been having issues upgrading VS2008 ASP.Net MVC1 projects to VS2010 ASP.Net MVC2.  In short, it doesn’t work so great.  OK.  It’s really lame.  There are two problems to address.  The VS2010 solution file uses a different format plus we’re upgrading library references in the background.  There’s more to it than that but you get the idea. 

I had been creating a new project and sliding things over, but that sucks.  So…  I get lazy and work on my older projects in VS2008 and the newer ones in VS2010.  Like I said, lame. 

Basically, I ignore the issue. 

(time passes) 

Read more…

WPF Challenges

April 22nd, 2010 No comments

Has anyone played with the old PresentationFramework.dll themes?  I usually use the WPF Themes from CodePlex, but I wanted to see how these themes would look.  After all, why wouldn’t I want my app to look like a windows app instead of some quasi-cartoon thingy?

I know I’ve been AWOL for a while.  I’ve been busy with the business.  Monday I searched for a charity.  Tuesday, my new laptop arrived.  I was too busy working through router issues.  Wednesday, I started playing with my laptop and researching a version control solution.  TFS will not work at the office.  I ended up with a free online service.  We’ll see if it works as planned.  Today was more laptop work and adding projects to Subversion.  Tomorrow, I have another new client meeting and a laptop to fix.  My old netbook migrated to my employee.  After Tuesday’s issues he can no longer connect to the network cleanly.

Read more…

New Interface for Visual Studio 2010 // Code Camp

March 13th, 2009 No comments

I found this blog entry today… VS2010 will use WPF and gets an update.
http://blogs.msdn.com/jasonz/archive/2009/02/20/a-new-look-for-visual-studio-2010.aspx

Portland Code Camp is scheduled for May 30-31, 2009. It will be held at Lewis and Clark College. (Event Link)