Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Generic argument types
 

Generic argument types

Hi again,

Is it possible at all to use generic types, like List<T>, as an argument type?

Example declaration :
<Argument Name="Test" Type="System.Collections.Generic.List&lt;T&gt;, mscorlib, Version=2.0.0.0" />

At compile-time and while registering I get no error, but when I try to use the Recipe that uses this argument, I get :

System.TypeLoadException: Could not load type 'System.Collections.Generic.List<T>' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.Practices.Common.Services.TypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.Practices.Common.Services.AliasResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.Practices.Common.Services.TypeResolutionService.GetType(String typeName, Boolean throwOnError)
at Microsoft.Practices.RecipeFramework.GuidancePackage.EnsureInitializeMetadataForCurrentRecipe()
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(IAssetReference reference)
at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()
at Microsoft.Practices.RecipeFramework.AssetReference.Execute()
at Microsoft.Practices.RecipeFramework.VisualStudio.RecipeMenuCommand.OnExec()
at Microsoft.Practices.RecipeFramework.VisualStudio.AssetMenuCommand.Invoke()
Renaud Bédard  Wednesday, May 31, 2006 6:55 PM
Generic types full name do not have the syntax you're specifying (which is the C# syntax). I'd suggest you write a little console app that does: Console.WriteLine(typeof(List<int>)) to see what you get. In addition, you cannot specify a generic type without specifying the actual type of the T.

Here's an example of how to use a generic list:

<Argument Name="Expiration" Type="System.Nullable`1[[System.TimeSpan]]" Required="false" />

In this release of GAT, only "T"s that can be specified without the assembly name (that is, only Ts from mscorlib) can be specified. If you need a List<Customer>, you will have to create a trivial class like the following, and use that as the argument type:

public class Customers : List<Customer> {}

HTH

kzu  Thursday, June 01, 2006 11:26 AM
Generic types full name do not have the syntax you're specifying (which is the C# syntax). I'd suggest you write a little console app that does: Console.WriteLine(typeof(List<int>)) to see what you get. In addition, you cannot specify a generic type without specifying the actual type of the T.

Here's an example of how to use a generic list:

<Argument Name="Expiration" Type="System.Nullable`1[[System.TimeSpan]]" Required="false" />

In this release of GAT, only "T"s that can be specified without the assembly name (that is, only Ts from mscorlib) can be specified. If you need a List<Customer>, you will have to create a trivial class like the following, and use that as the argument type:

public class Customers : List<Customer> {}

HTH

kzu  Thursday, June 01, 2006 11:26 AM
Thanks alot, that was informative. :)
Renaud Bédard  Thursday, June 01, 2006 1:54 PM

You can use google to search for other answers

Custom Search

More Threads

• Access Denied Error
• SiteMap Navagation getting covered up
• Licensing issue of Software Factory's Pre-requesites - GAX, GAT etc..
• How do i use the project name entered in the VS wizard
• Retreiving project for an unbound recipe
• SOA using WSSF and WCSF
• Files don't copy to UnitTesting Out folder ?
• a strange problem when we use Automation Toolkit
• Conditional Branching of Recipe Actions
• I have the need to create a Guidance Package but cannot find a tutorial.