Add View recipe and I.Interface assembly name

Topics: CAB & Smart Client Software Factory
Aug 1, 2006 at 2:10 AM
originally posted by: akol_dk

Hello

I have tried to change the name of the Infrastructure.Interface assembly to match the name of the Namespace. The project is still called Infrastructure.Interface.

When I change the assembly name, I can no longer use the "Add View" recipe - it does not show up in the menu anymore.

How do I fix this problem?

Regards
Anders
Aug 1, 2006 at 5:18 AM
originally posted by: askew

I would not change any of the generated code provided by SCSF, except to extend it per project.
Since I haven't ever tried to do this, I don't know what issues might result.

Is there a compelling reason for your need to rename it?
I don't understand the Namespace and assembly name concern that you have.
Aug 1, 2006 at 6:40 PM
originally posted by: DapinderSingh

Just check this post :
http://www.gotdotnet.com/codegallery/messageboard/thread.aspx?id=941d2228-3bb5-42fd-8004-c08595821170&mbid=62788f36-a963-4feb-8470-20f1a844ed2a&threadid=2a51d245-5f3d-45fa-bd53-45a8159dd1db

I think, in case you want to tweak the generated code, this is some what related way, you should go about doing it.
In case yuou get an idea of doing it, please post it back so that we too can be benefited with that.
Aug 1, 2006 at 9:50 PM
originally posted by: akol_dk

I guess I wasn't clear enough in my initial post.

I want to change the name of the .dll file from Infrastructure.Interface.dll to Full.Namespace.Infrastructure.Interface.dll.

The coding standard in the company I'm working for says that we should always use full namespace as name of the assembly (.dll) file. That's the main reason for me wanting to change the name. Besides if the company later desides to do another project using SCSF, it would be nice to be able to distinguish between the two versions of the Infrastructure.Interface.dll files. E.g. Full.Namespace1.Infrastructure.Interface.dll and Full.Namespace2.Infrastructure.Interface.dll. The two Infrastructure.Interface assemblies does not have to be the same.

Regards
Anders
Aug 1, 2006 at 11:46 PM
originally posted by: DapinderSingh

Anders,

If you refer to my previous post in which I have reffered to another post which is the only way to handle your requriement.

- Now consider an example where you create a sample application as "SampleApp". Now in this, all the default namespaces will get created as "rootnamespace.SampleApp.Infrastrcuture.*****"

- In the entire solution folder, replace all the "Infrastructure" keyword with some other name, suppose "TEST"

- Now all the solution files, either code / assebly files contains "rootnamespace.SampleApp.TEST.****"

- The moment you add a new buisness module in your solution, the Visual studio will add a default reference of the existing modules created by it as "rootnamespace.SampleApp.Infrastrcuture.*****" assuming that the default namespace is same as created at the solution creation time and no body has changed that.
Now to make this working, again a lot of changes need to be done which is an extreme overhead.

Now if you want to change this behaviour, you need to find such template files which contains the "Infrastucture" namespace name and you should change it to either pick it up from some config file or project name.

Browse the directory "C:\Program Files\Microsoft SCSF\GuidancePkg\bin\Templates\Text\WebServiceProxy" in your system and you will find certain ".T4" format files which cotnains hard coded strings "Infrastructure.**** ". This may be of some help to you.

As of now i have no idea how to do it but you can try it out but remmember this is a tricky thing ;-)
Aug 1, 2006 at 11:59 PM
originally posted by: akol_dk

Thank you for your answer.

I don't want to change the Infrastructure name. It is fine by me that the project is called Infrastructure.Interface. I have no problem with the namespace either. It is rootnamespace.SampleApp.Infrastructure.Interface. I don't want to change that. My namespace names are just fine.

The only thing I want to change is the output filenames of the .dll files that Visual Studio builds. The .dll file that Visual studio builds is called Infrastructure.Interface.dll. I would like to change this filename to rootnamespace.SampleApp.Infrastructure.Interface.dll. I do this by changing the properties for the Infrastructure.Interface project in Visual Studio.

When I change the name of the assembly (the .dll file) everything works just fine, except that I can no longer use the Add View recipe. My namespace is still the same, the name of the project is still the same. The only thing that has changed is the .dll file name.

It looks like the Add View recipe is only enabled if the project has a reference to the Infrastructure.Interface project. What I don't understand is, that this reference is still there, only the created .dll file have got a new name. The referenced project still has the same name.

Do you know where it is specified, when a recipe is enabled and when it is not enabled? The first thing would be to re-enable the recipe, and then I can see if it still works.

Regards
Anders
Aug 2, 2006 at 12:14 AM
originally posted by: DapinderSingh

I got it finally :-)

Yes, this is a problem because i think the guidance package checks for some dependencies before enabling / disabling the guidance package options.

But the fact is that if we want to acheive this kind of behavior, we need to change the template files as its because of these files and some internal implementaion, the guidance package checks for the " pre - specified " namespace dll and then act accordingly.

I think we can try the solution which i mentioned, it may be of some help.

Cheers!

Dapinder
Aug 19, 2006 at 8:44 AM
originally posted by: marianoszklanny

The ViewTemplateReference class in the References folder of the SmartClientDevelopment project in the GuidanceAutomation solution contains logic that determines if the Add View (with presenter) context menu should be shown when you right-click on an item in the solution explorer. This recipe adds code to a project that requires references to CAB, ObjectBuilder, and the Infrastructure.Interface project. Therefore the logic in the ViewTemplateReference class checks to make sure that you have clicked on a project node, and that the project has references to the required assemblies. If the project does not have the required references, you will not see the Add view (with presenter) menu item.

The ViewTemplateReference class contains a method named IsEnabledFor which contains the logic to determine whether the recipe has to be shown for a particular solution item or not. This method calls the ContainsReference method which checks if a project contains a specific reference.

The ContainsReference method contains the following code, with the intent of verifying a project reference:

if (reference.Identity == referenceIdentity) return true;

However, the Identity property checks the name of the assembly, and not the project. Therefore if you change the name of the assembly, but leave the project name unchanged, the Add view (with presenter) menu item stops appearing. To fix this, you can make the following changes to the ViewTemplateReference class:

1. Overload the ContainsReference method with the following code. This code checks if a project contains a reference to another project.

private bool ContainsReference(Project project, Project referenced)
{
if (project.Equals(referenced)) return true;
VSProject vsProject = (VSProject)project.Object;
foreach (Reference reference in vsProject.References)
{
if (reference.SourceProject != null && reference.SourceProject.Equals(referenced))
return true;
}
return false;
}

2. Update the ContainsRequiredReferences method to use the method you created in step 1:

private bool ContainsRequiredReferences(Project project)
{
DTE dte = GetService<DTE>();
if (!dte.Solution.Globals.get_VariableExists("CommonProjectGuid"))
return false;

Guid commonProjectGuid = new Guid((string)dte.Solution.Globals"CommonProjectGuid");
Project prjCommon = Utility.GetProjectFromGuid(dte, GetService<IServiceProvider>(), commonProjectGuid);

return ContainsReference(project, "Microsoft.Practices.CompositeUI") &&
ContainsReference(project, "Microsoft.Practices.ObjectBuilder") &&
ContainsReference(project, prjCommon);
}

Finally build the solution and register the guidance package (right-click the SmartClientDevelopment project and select "Register Guidance Package"). Make sure that no other instance of VS2005 is open when doing this.

For more information about recipe references check out this post:
http://staff.southworks.net/blogs/mariano/archive/2006/08/06/691.aspx

Cheers,
Mariano
Aug 23, 2006 at 12:03 PM
originally posted by: johnAtWatson

I have the same requirement to use our company namespace, and experienced the same issues today of not being able to Add View (with Presenter) Recipe, and my right click | Cab, isn't working.

I have the Add View Recipe in the Guidance Manager, but not in the Guidance Navigator. When I try to execute it the Recipe from the Manager, all of the projects/folders are greyed out, and Accept button is greyed out.

I tried the steps from the previous post, which seemed to go ok, it also added a new guidance package Smart Client Development(Custom), but still greyed out.

My issue may be related to that fact that I don't have the "Infrastructure" part of the namespace. I use MyCompanyNamespace.Interface, etc...

I tried just returning true from that function, but no dice.

Any ideas?
Aug 23, 2006 at 7:20 PM
originally posted by: DapinderSingh

Guys, I have got the solution for this.

To achieve what is required, you need to tweak the guidance package because in guidance package, all the paths are hard coded with "Infrastructure" keyword and the moment you change this keyword, all the things go for a toss.
Perform the following and you can achieve what you want to do :

1. Open the ..\Program Files\Microsfot SCSF folder and copy the GuidancePackage folder and GuidanceAutomation.sln to some other folder in the ..\Program Files\Microsoft SCSF\CustomeGuidancePackage.

2. Open the GuidanceAutomation.sln and Rename it to <YourCompanyName>GuidancePackage and add the reference to all the projects from "\Program Files\Microsoft SCSF\CustomeGuidancePackage" in this Solution .

3. Replace "Infrastructure" with "<YourCompanyName>" in the entire solution and leave the "Infrastrcuture" keyword as it is in the following files and lines.

C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\SmartClientDevelopment.xml(87): C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\SmartClientDevelopment.xml(150): C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Projects\Module\Module.Basic.cs.template(7):
C:\Program Files\Microsoft CSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Projects\Module\Module.Layout.cs.template(7):
C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Projects\Module.Business\Module.cs.template(7): C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Solutions\Projects\Infrastructure\Infrastructure.vstemplate(17):
C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Solutions\Projects\Module\Module.cs.template(7):
C:\Program Files\Microsoft SCSF\BPMEGuidancePkg\Source\SmartClientDevelopment\Templates\Solutions\SmartClient.vstemplate(19):

4. Open the "SmartClientDevelopment.xml" file and replace the Guid with a new GUID mentioned in the line below :

SmartClientDevelopment" Description="SmartClientDevelopment for BPM" BindingRecipe="BindingRecipe" Guid="7A030935-E5F3-4f08-BB42-EB41BEA08746" SchemaVersion="1.0">

5. Now build the entire solution to build a guidance package ( in release mode)

6. Uninstall the previously installed SmartClientDevelopmentSetup from Add/RemovePrograms.

7. Install the CustomeGuidancePackage.

8. Create a new project using custom guidance package and this will create a new project with the following projects :

<YourCompanyName>.Interface
<YourCompanyName>.Layout
<YourCompanyName>.Library
<YourCompanyName>.Module

9. Now all the assemblies will be created with the <YourCompanyName>.Layout.dll etc.
10. This work perfectly fine witthout any problem
This will work :-)
Aug 23, 2006 at 9:50 PM
originally posted by: akol_dk

Thank you, all of you for your replies and for your help.

We solved our problem with the solution given by Mariano. We have no problem with the project names, e.g. Infrastructure.Interface, but we needed to prefix the assembly name with out company namespace. That seems to be working now.

Regards
Anders
Jun 15, 2007 at 5:29 AM
I would think since you're really trying to get the Infrastructure.Interface library in order to run the recipe, rather than relying on assembly name (using whatever technique you want) both the project name and GUID for the project are in the .sln file. Why not just grab that as it's used by other parts of the factory. I think I'll look at modifying the guidance package this way rather than relying on some scheme to get the assembly name.
Aug 7, 2007 at 3:04 PM
I'm trying to do this to the the May 2007 release of SCSF, and I'm finding that several of the occurances of "Infrastructure" are not where they were. Could someone please post the new locations? Thanx in advance.

Yasko
Aug 13, 2008 at 4:29 PM

Hi

 

You can check the following article with the fix for the SCSF guidance package:

·         SCSF - April 2008 with VS2008 + SP1 Beta Known Issues

 

This fix was originally made for SCSF – April 2008 with VS 2008 + SP 1, but it also resolves the issue where the Add View with Presenter recipe disappears when you rename the Assembly Name of the Infrastructure.Interface project.

 

Please, let me know if it helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti

Nov 20, 2009 at 8:46 PM

Hi

 

About the add view with presenter option missing, it looks like I fix this using a very easy way..

 

Just change the Infrastructure.Interface name to <solution root>.Infrastructure.Interface

Feel free to let me know

Fchen