Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net ServiceReferences.ClientConfig加上慢速cheetah无法转换_.net_Visual Studio_Silverlight_Slowcheetah - Fatal编程技术网

.net ServiceReferences.ClientConfig加上慢速cheetah无法转换

.net ServiceReferences.ClientConfig加上慢速cheetah无法转换,.net,visual-studio,silverlight,slowcheetah,.net,Visual Studio,Silverlight,Slowcheetah,我在VS2010中有一个silverlight 5项目,希望根据我的配置更改其配置文件,就像更改web应用程序的数据库连接字符串一样 My ServiceReferences.ClientConfig如下所示: <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpB

我在VS2010中有一个silverlight 5项目,希望根据我的配置更改其配置文件,就像更改web应用程序的数据库连接字符串一样

My ServiceReferences.ClientConfig如下所示:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IWcfPortal" closeTimeout="00:10:00"
                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                maxBufferSize="25000000" maxReceivedMessageSize="25000000" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint name="WcfCslaService" address="http://localhost:22/Services/WcfSlPortal.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal"
            contract="WcfPortal.IWcfPortal" />
    </client>
</system.serviceModel>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel>
    <client>
        <endpoint name="WcfCslaService" address="http://192.168.0.0:22/Services/WcfSlPortal.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal"
                  xdt:Transform="Replace" />
    </client>
</system.serviceModel>

我的ServiceReferences.MyConfig.ClientConfig文件(通过右键单击,添加转换,使用慢速cheetah自动添加)如下所示:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IWcfPortal" closeTimeout="00:10:00"
                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                maxBufferSize="25000000" maxReceivedMessageSize="25000000" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint name="WcfCslaService" address="http://localhost:22/Services/WcfSlPortal.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal"
            contract="WcfPortal.IWcfPortal" />
    </client>
</system.serviceModel>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel>
    <client>
        <endpoint name="WcfCslaService" address="http://192.168.0.0:22/Services/WcfSlPortal.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal"
                  xdt:Transform="Replace" />
    </client>
</system.serviceModel>

我的问题是,没有替换整个节点(就像在同一个解决方案中我的web.config中所做的那样),转换不会发生。我尝试过清理/重建、手动删除.xap文件、一次生成一个项目。如果我查看silverlight project\bin文件夹并解压缩xap文件,它将包含所有ClientConfig文件,而主配置文件保持不变。我的xap文件中还有一个错误,在“xdt:Transform”下面加了一个下划线,上面写着“the”http://schemas.microsoft.com/XML-Document-Transform:Transform“未声明属性。”

如果我右键单击ServiceReferences.MyConfig.ClientConfig,预览转换将显示它应该显示的内容(具有更新IP地址的相同服务)。另一件疯狂的事情是,这之前是有效的,我不知道我做了什么来打破它(在我承诺回购之前就打破了)。我已经卸载并重新安装了慢速猎豹,重新启动等


有人知道如何修复此转换以使其正常工作吗?

如果您真正想做的只是替换地址,那么您可以尝试类似的方法(注意,我不是在使用SlowCheetah本身,但这种间接方法可能会给您足够的洞察力来解决问题)。我正在使用内置的转换机制,并连接到
BeforeBuild
AfterBuild
MSBuild目标

ServiceReferences.ClientConfig.Template
中,我有如下内容

<configuration>
  <system.serviceModel>
    <!-- ... -->
    <client>
      <endpoint
        name="Mine"
        address="http://localhost:8080/SomeService.svc"
        binding="basicHttpBinding"
        bindingConfiguration="..."
        contract="..."/>
    </client>
  </system.serviceModel>
</configuration>
其他一些(可能已经在您的解决方案中正确设置)“显而易见”的检查事项包括:

  • 确保Silverlight项目属性具有正确的
    .xap
    名称,并生成Silverlight清单文件
  • 确保Silverlight应用程序的web主机项目包含上述项目的名称,并将其放置在web中路径的
    ClientBin
  • 确保这两个项目的依赖项和构建顺序正确

    • 感谢Kit的帮助。最后,我花了一点时间研究这个问题,并使用不同的配置部署到几个不同的服务器上,并提出了以下解决方案:

    • 确保Web项目属性生成输出路径为\bin\并且在项目属性的Silverlight应用程序部分将特定于配置的文件夹设置为否
    • 确保Silverlight项目属性生成输出路径为\bin\(这是我的第一个问题)
    • 使用Slow Cheetah(简单)或修改silverlight项目的csproj xml(完成一次会有点痛苦,但也不错-下面是允许您对ServiceReferences.ClientConfig文件进行特定于配置的转换的方法)。使用slow cheetah,您可以通过右键单击特定于配置的转换来查看您的转换。我的和基特的改造工作
    • 将xml(取自上面的链接)添加到silverlight项目(csproj)文件中。它与Kit的类似,但不确定为什么他的不会编译,而这个会编译(这是我的第二个问题)-下面是xml
    • 重新生成项目,然后发布。.xap将包含转换后的ServiceReferences.ClientConfig文件
    • 如果希望与整个团队共享部署配置,请将MyProject.Publish.Xml添加到存储库中
    • 
      

      基特,谢谢你的回答。我发誓我试过在那里添加定位器几次,但都没有成功。我粘贴了它,更改了一些东西,现在.xap在silverlight项目中有了正确的配置文件,但是当我发布web项目时,ClientBin文件夹中包含的.xap文件具有未转换的配置文件。当我再次清理和重建silverlight项目时,甚至silverlight project.xap也不再包含转换后的配置——我又回到了原来的问题。当您在项目中进行此转换时,您是否看到它继续到..\yourWebProj\ClientBin\YourSLProj.xap?我更新了我的答案,希望它能让您更接近。我实际上并没有使用SlowCheetah,但这里可能有足够的细节,可以帮助您找到解决方案。如果您确定答案,请随意添加。Kit,什么是servicerences.Template.ClientConfig?这是你定制的模板吗?@Mario-是的。基本上希望有一个模板和ServiceReferences.*.Env.*.config文件进行版本控制,但没有ServiceReferences.ClientConfig,因为它是生成的。
       <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
       <Target Name="BeforeBuild" Condition="Exists('ServiceReferences.$(Configuration).ClientConfig')">
           <Move SourceFiles="ServiceReferences.ClientConfig" DestinationFiles="ServiceReferences.Build.ClientConfig" />
          <TransformXml Source="ServiceReferences.Build.ClientConfig" Destination="ServiceReferences.ClientConfig" Transform="ServiceReferences.$(Configuration).ClientConfig" />
       </Target>
       <Target Name="AfterBuild" Condition="Exists('ServiceReferences.Build.ClientConfig')">
           <Delete Files="ServiceReferences.ClientConfig" />
          <Move SourceFiles="ServiceReferences.Build.ClientConfig" DestinationFiles="ServiceReferences.ClientConfig" />
       </Target>