Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Important: Dynamically added references are working during buildtime, but not in designer mode of VS2008
 

Important: Dynamically added references are working during buildtime, but not in designer mode of VS2008

Hi

I posted a question in the msbuild forum -> thread , but it is better related here.
I don't know how to move the question. Please just answer in the msbuild forum.

Thanks a lot.
Schneebeli  Wednesday, September 02, 2009 10:58 AM
Background:
We have components with referencies. The dependencies of a component to another is stored in xml files.
Our buildtool is msbuild with custom applications and custom msbuild tasks. An application starts the compilation of the components in the right order.
We implemented a custom task 'CustomResolveReferences' to add the dependencies based on the xml files to the ITaskItem[] References.
<Target Name="BeforeResolveReferences">
	<CustomResolveReferences ProjectPath="$(ProjectDir)" Configuration="$(Configuration)">
		<Output TaskParameter="References" ItemName="Reference"/>
	</CustomResolveReferences>
</Target>

Problem:

That works perfectly to build the component in VS. But the designer of VS2008 and VS2005 can't find the dynamically added references. So we get errors like that when we want to open a form in designer:
Could not load file or assembly 'XwpMetaData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3a194cb621ebd9ba' or one of its dependencies. Das System kann die angegebene Datei nicht finden.

Call Stack:
at System.Signature._GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr declaringTypeHandle)
at System.Signature.GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandle fieldHandle, RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle)
at System.Signature..ctor(RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle)
at System.Reflection.RuntimeConstructorInfo.get_Signature()
at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
at System.RuntimeType.FilterApplyMethodBaseInfo(MethodBase methodBase, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
at System.RuntimeType.GetConstructorCandidates(String name, BindingFlags bindingAttr, CallingConventions callConv, Type[] types, Boolean allowPrefixLookup)
at System.RuntimeType.GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
at System.ComponentModel.BindingList`1.get_ItemTypeHasDefaultConstructor()
at System.ComponentModel.BindingList`1.Initialize()
at System.ComponentModel.BindingList`1..ctor()  

Special is aswell that under References in VS the dynamically added references are not listed. But they are loaded correctly during build, because the build works.

More Information:
Part of the code in the custom task 'CustomResolveReferences':
public class CustomResolveReferences : Task
{
        private ITaskItem[] references = new ITaskItem[0];
        //...

        [Output]
        public ITaskItem[] References
        {
            get { return references; }
        }
        //...
        
        public override bool Execute()
        {
                //...
                List<TaskItem> referenceList = new List<TaskItem>();
                //... for every dependency
                TaskItem item = new TaskItem(filePath);
                item.SetMetadata("Private", "False");
                referenceList.Add(item);
                //...
                references = referenceList.ToArray();
        }
}

More about BeforeResolveReferences target.

Question:
From where does the designer get the information about additional paths?
Is there an other variable except References which I have to set, that it works?
Has anyone some Ideas?

Thanks a lot.
Schneebeli  Tuesday, August 25, 2009 11:25 AM
Hi Schneebeli,

Sorry for the delay.

->Special is aswell that under References in VS the dynamically added references are not listed. But they are loaded correctly during build, because the build works.

I have readed your thread carefully, but I don't understand clearly, could you pleasepost more detailed?

And Ihighly suggest you post the question about Windows Forms Designerin our Windows Forms Designer forum, for I am not sure your question is related to MSBuild or Windows Forms Designer.

Best Regards,
Nancy


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao  Tuesday, September 01, 2009 10:33 AM
Hi Nancy

You're right, the question is more related to 'Windows Forms Designer'.
I posted a link there -> thread .

Normally you add additional referencies in VS, and they are saved in the .csproj in the ItemGroup Reference.

    <Reference Include="XwpMetaData">
      <HintPath>..\Import\XwpMetaData\Bin\$(Configuration)\XwpMetaData.dll</HintPath>
    </Reference>

We didn't do that, we change the References with a custom msbuild task, as described before.
And because of that, we aswell can't see the references in VS and the designer is not able to find the dll's.

Maybe we just have to add some additional search paths for the designer.
But I don't know how to do that.

Best Regards
Reto
Schneebeli  Wednesday, September 02, 2009 10:50 AM
Hi Reto,

I merged these two threads for other communitymembers could beconvenient to read.Good luck.

Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao  Thursday, September 03, 2009 1:42 AM
I really need some help.
Nobody has an idea?
Schneebeli  Friday, September 11, 2009 9:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Unwanted changes to designer file
• Need an HTML editor control
• Expose DataSet within Component
• Is there any way to spin through the objects in a property grid
• Any Difference between Form.Close and Form.Dispose?
• how to active mouse right click function?
• Form lost objects in design window
• Form Border Color Design/Appearance
• MenuStrip lost collection
• Possible BUG in RotateFlip