XamlParseException由于自己的VSTemplate(VS2010)上的System.Core

时间:2013-01-16 11:41:42

标签: c# visual-studio-2010 silverlight reference visual-studio-templates

中午,亲爱的社区。

我参与了构建包含2个项目,Web项目和silverlight项目的VSTemplate的练习。

解决方案VSTemplate:

<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>[...]</TemplateData>
<TemplateContent>
    <ProjectCollection>
        <ProjectTemplateLink ProjectName="$safeprojectname$_ClientSite">
            ClientSite\MyTemplate.vstemplate
        </ProjectTemplateLink>
        <ProjectTemplateLink ProjectName="$safeprojectname$_Client">
            Client\MyTemplate.vstemplate
        </ProjectTemplateLink>
    </ProjectCollection>
</TemplateContent>

Silverlight-Project VSTemplate:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateContent>
    <Project TargetFileName="$safeprojectname$.csproj" File="Uettingen_Client.csproj" ReplaceParameters="true">
        <Folder Name="dlls" TargetFolderName="dlls">
            <ProjectItem ReplaceParameters="false" TargetFileName="HST.Visualization.Controls.Silverlight.dll">HST.Visualization.Controls.Silverlight.dll</ProjectItem>
            [...]
        </Folder>
        <ProjectItem ReplaceParameters="true" TargetFileName="App.xaml">App.xaml</ProjectItem>
        <ProjectItem ReplaceParameters="true" TargetFileName="App.xaml.cs">App.xaml.cs</ProjectItem>
        <ProjectItem ReplaceParameters="true" TargetFileName="GlobalResources.xaml">GlobalResources.xaml</ProjectItem>
        <ProjectItem ReplaceParameters="true" TargetFileName="Head.xaml">Head.xaml</ProjectItem>
        [...]
        <Folder Name="Properties" TargetFolderName="Properties">
            <ProjectItem ReplaceParameters="true" TargetFileName="AppManifest.xml">AppManifest.xml</ProjectItem>
            <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
        </Folder>
        <Folder Name="Service References" TargetFolderName="Service References">
            <Folder Name="SLAuthenticationServiceReference" TargetFolderName="SLAuthenticationServiceReference">
                <ProjectItem ReplaceParameters="true" TargetFileName="configuration.svcinfo">configuration.svcinfo</ProjectItem>
                <ProjectItem ReplaceParameters="true" TargetFileName="configuration91.svcinfo">configuration91.svcinfo</ProjectItem>
                [...]
            </Folder>
        </Folder>
        <ProjectItem ReplaceParameters="true" TargetFileName="ServiceReferences.ClientConfig">ServiceReferences.ClientConfig</ProjectItem>
        [...]
    </Project>
</TemplateContent>

Silverlight项目文件:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
    [...]
    <ItemGroup>
        [...]
        <Reference Include="mscorlib" />
        <Reference Include="system" />
        <Reference Include="System.ComponentModel.Composition, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="System.Core" />
        <Reference Include="System.Net" />
        [...]
    </ItemGroup>
    <ItemGroup>
        <Compile Include="App.xaml.cs">
            <DependentUpon>App.xaml</DependentUpon>
        </Compile>
        <Compile Include="Page1.xaml.cs">
            <DependentUpon>Page1.xaml</DependentUpon>
        </Compile>
        [...]
        <None Include="Properties\AppManifest.xml" />
        <Compile Include="Properties\AssemblyInfo.cs" />
        <None Include="Service References\SLAuthenticationServiceReference\configuration.svcinfo" />
        <None Include="Service References\SLAuthenticationServiceReference\configuration91.svcinfo" />
    [...]
    </ItemGroup>
    <ItemGroup>
        <ApplicationDefinition Include="App.xaml">
            <SubType>Designer</SubType>
            <Generator>MSBuild:Compile</Generator>
        </ApplicationDefinition>
        <Page Include="Page1.xaml">
            <SubType>Designer</SubType>
            <Generator>MSBuild:Compile</Generator>
        </Page>
        [...]
        <WCFMetadata Include="Service References\" />
        <WCFMetadataStorage Include="Service References\SLAuthenticationServiceReference\" />
        <Content Include="ServiceReferences.ClientConfig" />
        <Page Include="SplashWindow.xaml">
            <SubType>Designer</SubType>
            <Generator>MSBuild:Compile</Generator>
        </Page>
    </ItemGroup>
    <ItemGroup>
        <Folder Include="img\" />
    </ItemGroup>
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
        <ProjectExtensions>
        <VisualStudio xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
            <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
                <SilverlightProjectProperties />
            </FlavorProperties>
            <UserProperties VisiWinNETProductType="VisiWin7" VisiWinNETRuntimeType="Standard" VisiWinNETVersion="7.0" VisiWinNETProjectName="$safeprojectname$" />
        </VisualStudio>
    </ProjectExtensions>
</Project>

我缩短了这一点,虽然它很简单,但它的工作(几乎)完美无缺。 System.Core存在问题:

编译生成的项目后,它会在App.xaml.cs的InitializeComponents();的构造函数中的App上抛出一个exeption:

System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

现在我正在检查System.Core,我意识到一些奇怪的事情:

  • 手工制作的项目当然很好。只是没有生成的个人资料。
  • 构建成功,这是运行时错误。
  • 我生成的解决方案的System.Core可用,编译前没有错误。
  • 删除System.Core后,我无法重新添加它(Visual Studio不显示任何消息,只是不添加消息。
  • 重启Visual Studio和整个操作系统无济于事。在生成的项目之后,甚至没有手动添加我的System.Core。
  • 我尝试在本地提供我的模板/生成项目所需的System.Core,问题完全相同。
  • 我试图清理所有并重建它
  • 我尝试将<Reference Include="System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /><Reference Include="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />放入Uettingen_Client.csproj而不是<Reference Include="System.Core" />,4.0.0.0部分将错过来源
  • 我尝试删除csproj中的引用条目,并将<References><Reference><Assembly>System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Assembly></Reference></References><References><Reference><Assembly>System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Assembly></Reference></References>插入项目VSTemplate文件的TemplateContent部分。这根本不起作用,System.Core甚至没有显示为条目。
  • 我正在使用WinMerge将生成的silverlight项目与之前的手工项目(我之前转换为模板)进行比较。除了像空格这样的格式,除了服务引用之外,项目似乎都匹配。
  • 如果我尝试添加4.0.0.0,则会出现冲突警告。
  • 在最上面的示例中,有时清除,构建和运行后不会出现任何错误,但Silverlight元素是完全白色的。

有什么想法吗?

0 个答案:

没有答案