Bookmark and Share

GacUtil, MPF, and CSProj

by KodefuGuru 30. April 2009 10:53

Yesterday, I wrote about running GacUtil from within the AfterBuild target, due to some constraints with MPF and T4.

I discovered that the path I provided was wrong. It's the only GacUtil.exe under the Microsoft.NET folder, but it won't register the assembly. Since I wasn't sure which path I should be using, I used the GacUtil task from MSBuild Community Tasks. Here is the relevant code it uses to retrieve the path to gacutil.exe:

protected override string GenerateFullPathToTool()
{
    
return ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(ToolName, TargetDotNetFrameworkVersion.Version20);
}
protected override string ToolName
{
    
get { return "gacutil.exe"; }
}
This was fine, but it turns out that you get an error from regpkg.exe if the assembly is location in the GAC if you're trying to generate from a path.
regpkg : warning : The Assembly specified at [Path]\[Assembly]cannot be loaded because an alternate copy with the same identity exists in the Assembly probing path at 'C:\WINDOWS\assembly\GAC_MSIL\[Assembly]\1.0.0.0__7c2bf94927fd6e28\[Assembly]. The Assembly at 'C:\WINDOWS\assembly\GAC_MSIL\[Assembly]\1.0.0.0__7c2bf94927fd6e28\[Assembly] will be loaded instead.
regpkg : error : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
  Could not load file or assembly '[Assembly], Version=1.0.0.0, Culture=neutral, PublicKeyToken=7c2bf94927fd6e28' or one of its dependencies. The system cannot find the file specified.
To fix this, I made the GacUtil uninstall the assembly in the BeforeBuild target. However, I kept receiving the same error. Generating a diagnostic log from MSBuild showed me the actual culprit: the RegisterManagedPackage target builds after the AfterBuild target. I fixed it by making AfterBuild depend on RegisterManagedPackage. I've pasted the final, relevant script below. Note that the RegPkg command in the AfterBuild is used to generate installer wix. TargetName is used in the GacUtil uninstall because it requires the name without the extension.
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<
Target Name="BeforeBuild">
   <
GacUtil Command="Uninstall" Assemblies="$(TargetName)" ContinueOnError="true"/>
</
Target>
<
Target Name="AfterBuild" DependsOnTargets="RegisterManagedPackage">
  <!--
.wix is specified instead of .wxi because the RegPkg task requires it to generate the wix script. -->
   <
RegPkg ItemToRegister="$(TargetPath)" ProductVersion="$(TargetVSVersion)" SDKVersion="$(VsSDKVersion)" OutputFile="..\Installer\RegistryEntries.wix" Unregister="false" UseCodeBase="false" UseRanu="false" />
   <
GacUtil Assemblies="$(TargetPath)"/>
</
Target>
Bookmark and Share

GacUtil from Project File

by KodefuGuru 29. April 2009 17:17

Due to circumstances involving a MPF package and Text Templating (t4), I had to add an assembly to the GAC after compiling if I wanted to be able to run the generator in the VS Experimental. So, I added the following line to the AfterBuild target of the csproj file:

<Exec Command="gacutil /i $(TargetPath)"/>

Unfortunately, I received the following error when I compiled: 

Error 155 The command "gacutil /i [PathToDll]" exited with code 9009. C:\Projects\AperioVisualStudioAddins\AperioVisualStudioAddins\AperioVisualStudioPackage.csproj 202 2 [DllName]

The problem is that when Visual Studio is building the project, it does not have access to the path. The way to make it work is to specify the fully qualified path and filename to gacutil.

<Exec Command="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe /i $(TargetPath)"/>

Bookmark and Share

Custom Tags

by KodefuGuru 29. April 2009 15:38

Microsoft Tag is a cool technology that revolutionizes barcodes. A while back, I created my own tag for KodefuGuru.com. While building a new presentation to give at the Farm Bureau Spring Conference, I decided I should embed my tag in the presentation. I couldn't find the file I saved out, so I browsed out to the site and discovered Microsoft has put together a way to allow branding and design in the tag itself. Welcome to custom tags!

Tags:

General

Bookmark and Share

Word Math Zones

by KodefuGuru 27. April 2009 13:30

I didn't realize you could do this. If you want a math zone in Office Word, just type Alt+=. This will allow you to enter equations with simple notation. If you type a^2+ b^2=c^2 for Pythagoras algorithm, it will convert give you a nice graphical representation.

Pythagoras

While you're in the equation editor, a cool ribbon appears that allows you to edit an equation even if you aren't aware of the linear notation.

Equation Editor

 

If I wanted to write an equation in the past for posting, I would have to hunt down a pregenerated image, use linear notation, or find a third party tool. This is a lot easier.

Bookmark and Share

Richmond Code Camp

by KodefuGuru 23. April 2009 13:25

Tomorrow after work, I'm driving to Richmond to speak at the Richmond Code Camp. In the past, I didn't plan out which sessions I would attend. Instead, I just floated to whatever seemed interesting. This time, I'm taking the steps to get the most out of the conference. Here's my schedule.

8:00 - 8:45am - Auditorium - Welcome And Keynote

I'm not a morning guy, particularly after driving 6 hours. However, I'll try to be on time to catch the keynote.

8:45 - 10:00am - Speakers Lounge - Preparation

Before I give a talk, I like to review my material.

10:15 - 11:30am - Room 223 - Introducing MSBuild - Chris Eargle

My talk. I would be disappointed if I wasn't there.

11:30 - 12:30pm - Lunch

Lunch will most likely consist of pizza. Were you aware that researchers have discovered that people who eat pizza at least once a week are at a lower risk for certain cancers?

12:30 - 1:45pm - Room 220 - Guerilla SOA on WCF - Joshua Graham

I love SOA, and I love WCF. I'm not so sure about the guerilla part.

2:00 - 3:15pm - Auditorium - How to Give Technical Presentations: 101 - Hal Hayes

Maybe I can learn a few tricks to make my presentations better?

3:30 - 4:45pm - Room 210 - Implementing validation when using the ASP.NET MVC Framework - Roberto Hernandez

I'm curious about the validation techniques used when you don't have postbacks. In a layered application, I use UI validation only to provide a better user experience. I would expect true validation to occur in the business or service layer.

5:00 - 5:30pm - Auditorium - Wrap Up and Prizes

The fun part. I haven't won an Xbox 360 yet.

 

Bookmark and Share

Tour of Fog Creek

by KodefuGuru 22. April 2009 16:24

Get Microsoft Silverlight

In this video on Channel 9, Scott Hanselman tours the new Fog Creek Software offices. After seeing the height adjusted desks, gigantic montors, and private offices, I find myself rather envious!

Bookmark and Share

Team System 2010 Overview

by KodefuGuru 21. April 2009 09:23

Brian Harry has posted a list of features that will be in the upcoming beta 1 of Visual Studio 2010 Team System. Unfortunately, the date of release for beta 1 has not been announced yet.

Architecture (http://blogs.msdn.com/camerons/)

  • Architecture Explorer
  • Layer diagram
  • Use case designer
  • Activity designer
  • Component diagram
  • Logical class designer
  • Sequence diagram
  • Modeling project system
  • UML Model explorer
  • Architecture validation during build

Development & Database (http://blogs.msdn.com/habibh/)

  • Historical debugging
  • Test impact analysis
  • Improved code analysis
  • Improved profiling (especially multi-tier)
  • Database extensibility

Lab Management (http://blogs.msdn.com/amit_chatterjee, http://blogs.msdn.com/lab_management)

  • Multi-tier Environment creation and management
  • Automated deployment
  • Easily manage machine pools
  • Network fencing
  • Checkpoints

Test (http://blogs.msdn.com/amit_chatterjee, http://blogs.msdn.com/james_whittaker)

  • Test planning
  • Test case management
  • Test prioritization
  • Run management & reporting
  • Project quality reports
  • Manual test execution
  • Diagnostic recording (environment, video, etc)
  • UI Automation recording
  • Coded UI tests

TFS (my blog http://blogs.msdn.com/bharry)

  • Work item hierarchy & linking
  • Improved Agile template
  • MOSS & WSS Dashboards
  • Simplified reporting
  • Improved support for parallel development
  • Rollback
  • Build queuing and pooling
  • Gated checkin
  • Simplified setup
  • Scale out of web and data tiers
  • Admin console
  • Project move/archive/restore
Bookmark and Share

Package Load Key Issue

by KodefuGuru 20. April 2009 18:24

I finished up a Visual Studio package, generated the package load key (plk), created an installer, and deployed it to a tester. Of course, it didn't work. Whenever the tester tried to open up the designer, the following error was displayed (note: the screenshots don't reflect the actual product as it is proprietary).

Package Load Failure - Package 'XmlDesigner.VsPackage, XmlDesigner, Version=1.0.3397.31516, Culture=neutral, PublicKeyToken=0a7205e1305966ea' has failed to load properly (GUID = {EB5B62E8-85C8-40AB-862B-98DFD1FAC2A2} ). Please contact package vender for assistance. Application restart is recommended, due to possible environment corruption. Would you like to disable loading this package in the future? You may use 'devenv /resetskippkgs' to re-enable package loading.

To duplicate the environment, I downloaded a set up a virtual pc with Visual Studio Team System 2008. I did a lot of testing and discovered that it would load up fine when the sdk was installed. That's when I realized I never tested the package with the /NoVSIP switch for devenv.exe. Once I did, I received the same messages on my workstation.

I opened the package in the Package Load Analyzer and received the following message.

Visual Studio Package Load analysis for package {eb5b62e8-85c8-40ab-862b-98dfd1fac2a2} failed. Following Verification(s) failed:-

Plk Verification

A few people in the forums had similar issues, but the response was always the same: "PLK failures almost always result from a typographical error." As some people suggested, I ran devenv.exe with the log switch on, but it didn't provide any more information than the Package Load Analyzer. I generated keys several times, checked and double-checked that all the information was correct in the ProvideLoadKey attribute. Finally, I started playing around with the the resource file. That's when I discovered that there were line breaks in the plk. I removed the line breaks, and the package finally started loading!

If you generate the plk on Microsoft's website, it inserts line breaks. Of course, it's pretty long, so you're likely to copy and paste it into the resource designer. If you don't remove the line breaks, you will have the same problem.

Tags:

Kodefu

Bookmark and Share

Illustrated C# 2008 eBook

by KodefuGuru 13. April 2009 09:17

Migrating to C# from C++ or VB? Redgate is offering an ebook of Illustrated C# 2008 by Daniel Solis to help you out. It has a very visual approach, with lots of figures and code samples. Best of all, it's free!

 

Tags:

Training

Bookmark and Share

Mapping Fail with Entity Framework

by KodefuGuru 13. April 2009 00:42

While beginning a new project for myself, I decided to use the Entity Framework by building my entities first then creating the database required to support the entities I need. When I reached the stage where I had to map the relationships to the database, I wasn't exactly sure what to put in. I eventually figure out that I need to set the table mapping to the table with the many multiplicity, then set the tables to their corresponding keys in that table.

I originally set them to the same key before I looked at how the designer did it if you generated the edmx from the database. When I set the relationships to the correct keys, I kept receiving the following error:

Error 113: Multiplicity is not valid in Role in relationship X. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be 1.

I kept twiddling with things, trying to get the error message to go away. It turned out that before you can change the column mapping, you have to click delete in the drop down before you can select another column and have it persist correctly. Also, for some reason, it really didn't like me editing the xml. Watch out for this if you prefer to create your entities before the database.

KodefuGuru.GetInfo()

Chris Eargle
LinkedIn Twitter Technorati Facebook

Chris Eargle
C# MVP, INETA Community Champion


MVP - Visual C#

 

INETA Community Champions
Friend of RedGate
Telerik .NET Ninja
Community blogs & blog posts

I am a #52er

I have joined Anti-IF Campaign


World Map

Tag cloud

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010