SCSF - April 2008 with Visual Studio 2008 Service Pack 1 Known Issues

Contents


NOTE: This fix has been smoke tested and also works with Visual Studio 2008 Service Pack 1 and .NET Framework 3.5 Service Pack 1

Add View recipes are not displayed

The Add View (with Presenter) and Add WPF-View (with Presenter) recipes are not displayed in a Visual Basic solution created with the SCSF – April 2008 in Visual Studio 2008 with Service Pack 1 Beta.
ViewRecipesIssue.png

Cause

The Guidance Package verifies if the project where the views will be added has the following references to enable the Add View (with Presenter) and Add WPF-View (with Presenter) recipes:
  • Microsoft.Practices.CompositeUI assembly
  • Microsoft.Practices.ObjectBuilder assembly
  • Infrastructure.Interface project
The project templates used by the SC-SF have the $RootNamespace$ variable as a prefix in the AssemblyName project’s property.
<AssemblyName>$RootNamespace$.Infrastructure.Interface</AssemblyName> 

It seems that in Visual Studio 2008 without SP1, the Create Smart Client solution recipe ignores the $RootNamespace$ variable in the assembly name, therefore the assembly name is always set as Infrastructure.Interface.
Using the SP1 in Visual Studio 2008, the $RootNamespace$ variable is replaced and the recipe does not find the dependency on the Infrastructure project because it is searching for an incorrect name.

Fix

To fix this issue, you need to modify the Guidance Package source code and register a custom one.

To fix Add View recipes are not displayed issue perform the following steps:
  • 1. Open the GuidancePackage.sln solution.
  • 2. In Solution Explorer, open the ViewTemplateReferenceVB.cs file located in the References folder of the SmartClientFactoryPackage project.
  • 3. Find the following line in the file:
Line #154: if (reference.Identity == referenceIdentity) return true; 
  • 4. Replace the preceding line with the following one:
Line #154: if (reference.Name == referenceIdentity) return true; 
  • 5. Repeat steps 3 and 4 for the ViewTemplateReferenceCS.cs file located in the References folder of the SmartClientFactoryPackage project (Line 153).

New SC-SF solutions do not run

When you create a new SC-SF solution and run it (F5), the DependentModuleLoaderService service throws a ModuleLoadException exception when trying to load one of your modules.
Exception.png

Cause

All the projects generated with the Guidance Package have the $RootNamespace$ variable as a prefix in the assembly name, so the .dll files generated when you build the solution will also have the same prefix:
<AssemblyName>$RootNamespace$.Infrastructure.Module</AssemblyName> 

However, in the ProfileCatalog.xml file, the assemblies’ names do not include the $RootNamespace$ prefix:
<ModuleInfo AssemblyFile="Infrastructure.Module.dll" /> 

Fix

To fix this issue, you need to modify the Guidance Package source code and register a custom one.
To fix New SC-SF solutions do not run issue perform the following steps:
  • 1. In Solution Explorer, open the CreateSmartClientFactoryBusinessModuleCommon.xml file located in the Recipes\Common folder of the SmartClientFactoryPackage project.
  • 2. Find the following line in the file:
Line #104: <Input Name="ModuleName" RecipeArgument="ModuleName"/> 
  • 3. Replace the preceding line with the following one:
Line #104: <Input Name="ModuleName" RecipeArgument="ModuleNamespace"/> 
  • 4. Repeat steps 2 and 3 for the CreateSmartClientFactoryFoundationalModuleCommon.xml file located in the Recipes\Common folder of the SmartClientFactoryPackage project (Line 106).
  • 5. In Solution Explorer, open the ProfileCatalog.xml file located in the Templates\Solutions\Projects\Shell.Basic.CS folder of the SmartClientFactoryPackage project.
  • 6. Find the following line in the file:
Line #4: <ModuleInfo AssemblyFile="Infrastructure.Module.dll" /> 
  • 7. Replace the preceding line with the following one:
Line #4: <ModuleInfo AssemblyFile="$RootNamespace$.Infrastructure.Module.dll" /> 
  • 8. Repeat steps 6 and 7 for the ProfileCatalog.xml file located in the Templates\Solutions\Projects\Shell.Basis.VB folder of the SmartClientFactoryPackage project.
  • 9. In Solution Explorer, open the ProfileCatalog.xml file located in the Templates\Solutions\Projects\Shell.Extended.CS folder of the SmartClientFactoryPackage project.
  • 10. Find the following lines in the file:
Line #4:  <ModuleInfo AssemblyFile="Infrastructure.Layout.dll" />
Line #12: <ModuleInfo AssemblyFile="Infrastructure.Module.dll" />  
  • 11. Replace the preceding lines with the following ones:
Line #4:  <ModuleInfo AssemblyFile="$RootNamespace$.Infrastructure.Layout.dll" />
Line #12: <ModuleInfo AssemblyFile="$RootNamespace$.Infrastructure.Module.dll" /> 
  • 12 .Repeat steps 10 and 11 for the ProfileCatalog.xml file located in the Templates\Solutions\Projects\Shell.Extended.VB folder of the SmartClientFactoryPackage project.
  • 13. Compile and Register the fixed Guidance Package.

Fix that works both with and without SP1 Beta

If you want to enable the GP to be used both with and without Service Pack 1, after performing the previous fixes you must do the one that follows:
  • 1. Open the Smart Client Guidance Package Solution.
  • 2. In the Actions folder create a new class named SetProjectAssemblyNameAction.cs.
  • 3. Add the following code to the created class:
using EnvDTE;
using System;
using System.Collections.Generic;
using Microsoft.Practices.RecipeFramework;
using Microsoft.Practices.RecipeFramework.Library;
using Microsoft.Practices.RecipeFramework.Library.CodeModel;
using System.Globalization;

namespace Microsoft.Practices.SmartClientFactory.Actions
{
    public class SetProjectAssemblyNameAction : ConfigurableAction
    {
        [Input(Required = true)]
        public Project Project
        { get; set; }

        [Input(Required = true)]
        public string RootNamespace
        { get; set; }

        public override void Execute()
        {
            Project.Properties.Item("AssemblyName").Value = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", RootNamespace, Project.Name);
        }

        public override void Undo()
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
} 
  • 4. Locate the SmartClientFactoryPackage project open the Recipes folder and open the file CreateSmartClientFactorySolutionCommon.xml located in the Common folder.
  • 5. Add the following code in bottom of the ActionsAddReferences tag:
<!--Set the correct assembly names-->
<Action Name="SetInterfaceAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
	<Input Name="Project" RecipeArgument="InterfaceProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetLibraryAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
	<Input Name="Project" RecipeArgument="LibraryProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetModuleAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
	<Input Name="Project" RecipeArgument="ModuleProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetShellAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
	<Input Name="Project" ActionOutput="CreateShellProjects.ShellProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetLayoutAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage"
Condition="$(CreateShellLayoutModule)">
	<Input Name="Project" ActionOutput="CreateShellProjects.LayoutProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action> 
  • 6. Add the following code to the CreateSmartClientFactoryFoundationalModuleCommon.xml inside the ActionsUpdateProfileCatalog tag at the buttom:
<!--Set the correct assembly names-->
<Action Name="SetFoundationalModuleAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
	<Input Name="Project" ActionOutput="UnfoldModuleProjects.ModuleProject" />
	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetFoundationalModuleInterfaceAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage"
            Condition="$(CreateModuleInterfaceLibrary)">
     	 <Input Name="Project" ActionOutput="UnfoldModuleProjects.ModuleInterfaceProject" />
     	 <Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetFoundationalModuleTestAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage"
            Condition="$(CreateTestProject)">
      	<Input Name="Project" ActionOutput="UnfoldModuleProjects.TestProject" />
      	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action> 
  • 7. Add the following code to the CreateSmartClientFactoryBusinessModuleCommon.xml inside the ActionsUpdateProfileCatalog tag at the buttom:
<!--Set the correct assembly names-->
<Action Name="SetBusinessModuleAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage">
      	<Input Name="Project" ActionOutput="UnfoldModuleProjects.ModuleProject" />
      	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetBusinessModuleInterfaceAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage"
            Condition="$(CreateModuleInterfaceLibrary)">
      	<Input Name="Project" ActionOutput="UnfoldModuleProjects.ModuleInterfaceProject" />
      	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action>
<Action Name="SetBusinessModuleTestAssemblyName" Type="Microsoft.Practices.SmartClientFactory.Actions.SetProjectAssemblyNameAction, Microsoft.Practices.SmartClientFactory.GuidancePackage"
            Condition="$(CreateTestProject)">
      	<Input Name="Project" ActionOutput="UnfoldModuleProjects.TestProject" />
     	<Input Name="RootNamespace" RecipeArgument="RootNamespace" />
</Action> 
  • 8. Open the folder CS located inside Recipes.
  • 9. Add the following code to the buttom of the UnfoldModuleProjects action of the CreateSmartClientFactoryFoundationalModule.xml file:
<Output Name="ModuleProject"/>
<Output Name="ModuleInterfaceProject"/>
<Output Name="TestProject"/> 
  • 10. Open the folder VB located inside Recipes.
  • 11. Add the following code to the buttom of the UnfoldModuleProjects action of the CreateSmartClientFactoryFoundationalModule.xml file:
<Output Name="ModuleProject"/>
<Output Name="ModuleInterfaceProject"/>
<Output Name="TestProject"/> 
  • 12. Compile and register the Guidance Package.

Last edited Oct 6, 2008 at 7:35 PM by mconverti, version 18

Comments

alna Apr 10, 2010 at 7:55 PM 
Hi,

I recently tried the SCSF Contrib project and ended up with the same issue. Originally I thought the SCSF Contrib project has something to do with it, but I was wrong. After reading this post and experimenting with few new SCSF solutions here is what helped in my case for issues #1 and #2:

1. Create a new SCSF solution called Test1.
2. Run the solution and it will throw an exception that it cannot find Test1.Infrastructrure.Interface.dll (issue #2). The solution to that is to open the ProfileCatalog.xml in the Shell project and edit the line:
<ModuleInfo AssemblyFile="Infrastructure.Module.dll" />
to
<ModuleInfo AssemblyFile="Test1.Infrastructure.Module.dll" />
3. Try to add new View in the Shell project by right clicking on it and you will see that the Add View menu is not there (issue #1). The solution to that is to rename all infrastructure projects from:
Infrastructure.Interface
Infrastructure.Library
Infrastructure.Module
to
Test1.Infrastructure.Interface
Test1.Infrastructure.Library
Test1.Infrastructure.Module

After that both issues #1 and #2 were fixed for me.

luisxvarg Dec 29, 2009 at 10:07 PM 
Hi Mariano I did your fix but I get the follow exception when load the package:
Cannot Load Package Smart Client Software Factory.
How can I do a correct register of dll?
This fix no works for me.
Thanks Luis

Fchenatwork Nov 20, 2009 at 7:57 PM 
http://smartclient.codeplex.com/Thread/View.aspx?ThreadId=6211

I fix it using a very easy way.

jhollida Feb 9, 2009 at 12:23 PM 
If you only copy the updated DLL from source to prod you also have to copy a couple of extra files before the View Context menus show up in existing projects. In the Guidance Package you'll need to copy from your source to prod;
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Microsoft.Practices.SmartClientFactory.GuidancePackage.dll
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\SmartClientFactoryPackageInstallerApr2008.dll
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Recipes\Common\CreateSmartClientFactoryBusinessModuleCommon.xml
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Recipes\Common\CreateSmartClientFactoryFoundationalModuleCommon.xml
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Templates\Solutions\Projects\Shell.Basic.CS\ProfileCatalog.xml
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Templates\Solutions\Projects\Shell.Basic.VB\ProfileCatalog.xml
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Templates\Solutions\Projects\Shell.Extended.CS\ProfileCatalog.xml
C:\Program Files\Microsoft Smart Client Factory April 2008\Guidance Package\Templates\Solutions\Projects\Shell.Extended.VB\ProfileCatalog.xml
This assumes you've already edited the existing applications Shell "ProfileCatalog.xml" file to include the namespace prefix for existing applications;
<ModuleInfo AssemblyFile="AdventureWorks.Infrastructure.Module.dll" />

I do agree that it would be nice if there was a latest patched version for download so everyone doesn't have to do it themselves.

statcomp Feb 7, 2009 at 3:01 PM 
No this does not fix the problem #1. The "fix" will only work at first time you try to create a view in a module without compilation. Once you compile the solution, you can't see the Add Vew context menu at all from the module. Problem #1 is closely related to Problem #2. Here is my temporary (and messy) way to make the context menu appear :

1 go to Infrastructure.Interface project ,
2 go to its properties,
3 take off solution name from its assembly name. Then you will be able to see the context menu. Of course, application will not run and I warned you it's temp,

Artazor Dec 7, 2008 at 3:35 AM 
Hi, I've packaged all this stuff into single MSI installer.
It is avialable at http://artazor.wordpress.com/2008/12/07/scsf-april-2008-fix-for-visual-studio-2008-sp1/
Also I've bundled original HxS Help files from SCSF April 2008 making this package a sufficient standalone replacement of SCSF April 2008.
You can try it out, and feedback would be appreciated.

vyashiral Oct 23, 2008 at 5:34 AM 
update: I agree with entwickler. Fix works fine with new project but when we open the existing project it does not give the option "Smart Client Developer for SP1" option under Guidance package. Is there any work around for it?

entwickler Aug 28, 2008 at 10:08 AM 
update: This fix works if you create new project, but not for the old ones

entwickler Aug 27, 2008 at 1:27 PM 
One more comment, the same issues are valid for SP1 RTM

entwickler Aug 22, 2008 at 8:05 AM 
Why don't you build and pack a version for the people with SP1 instead of writing complex guides for fixes?
Thanks