我正在学习WCF,特别是我正在学习如何将它们写成合同,ala wscf.blue
我可以创建一个WCF客户端/服务合同的最后一种方式(微软)我可以创建一个WCF客户端/服务合同的第一种方式(WSCF)
但是,如果我创建合同第一个服务,然后尝试添加Microsoft方式(服务参考)而不是WSCF.blue方式(共享合同和生成客户端)它不起作用.
它会抛出一条ActionNotSupportedException消息The message with Action 'urn:test-com:simple:testMethodIn' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
我不知道这意味着什么.
这是我的测试合同:
SimpleModel.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="urn:test-com:simple" xmlns:mstns="urn:test-com:simple" …Run Code Online (Sandbox Code Playgroud) 您显然能够在不丢弃.NET中的堆栈跟踪的情况下重新抛出异常.
但它似乎没有起作用.
因此我遵循的基本用法是:
[WebMethod]
public void ExceptionTest()
{
try
{
throw new Exception("An Error Happened");
}
catch (Exception ex)
{
evlWebServiceLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,行中的行中的throw;行号,而不是原始throw new行.
我在一个简单的exe项目中测试了它,没有登录到Windows日志行.它没有任何区别,堆栈跟踪总是包含错误的行号,使其不太有用.
它为什么这样做?我该怎么做?
我们开发了一个存储语言翻译信息的.NET程序集,它需要由VB6应用程序使用.
我们希望能够更改翻译信息,而无需重新编译应用程序.
翻译由名为LanguageServices的双文件分部类提供.
一个文件是不变的库方法,另一个是来自resx文件的所有自动生成的属性,并且regx是从语言翻译信息的数据库生成的.
这一切都源于需要拥有一个翻译的中央数据库,这些数据库可以编程"扁平化"为我们每个不同应用程序可以使用的格式.
现在,我可以通过绕过它并以不同的方式来解决这个问题.事实上,我可以摆脱自动生成的属性列表,问题就会消失.
我感兴趣的是如何解决这个问题,因此:
如果我们向数据库添加新的翻译标签(这个字中的这个字变成了那个字),它会向类添加新的属性,这又为COM接口添加了新的公开属性.
这些属性被添加到COM接口的中间,从而破坏了二进制兼容性.它们被添加到中间,因为C#编译器使用分部类的静态部分为部分类的动态部分添加后缀.我需要做的是以相反的方式连接它们或者在C#文件本身中明确说明顺序.我认为在类的静态部分显式设置DispID会做到这一点,但事实并非如此.
以下是构建过程生成的一对IDL文件:
这是我添加新属性之前的IDL.
以下是添加新属性并且兼容性被破坏后的IDL:
确切的区别是这个位置被推到中间:
[id(0x60020039), propget]
HRESULT Jn_ExactCaseMatch([out, retval] VARIANT_BOOL* pRetVal);
[id(0x6002003a), propget]
HRESULT Jn_Regex([out, retval] VARIANT_BOOL* pRetVal);
[id(0x6002003b), propget]
HRESULT Jn([out, retval] BSTR* pRetVal);
Run Code Online (Sandbox Code Playgroud)
我认为这是问题,它改变了方法的顺序.我认为可以通过显式定义DispID来覆盖订单(您可以看到从头HRESULT Culture([in] ICultureInfo* pRetVal);开始的所有内容都有一个从0开始的id.
这是编写/生成的C#代码:ILanguageServices.cs:自动生成的界面.
[Guid("547a7f6e-eeda-4f77-94d0-2dd24f38ba58")]
public partial interface ILanguageServices
{
/// <summary>
///
/// </summary>
System.Boolean Offence_ExactCaseMatch { get; }
/// <summary>
///
/// </summary>
System.Boolean Offence_Regex { get; }
/// <summary>
///
/// </summary>
string Offence { get; …Run Code Online (Sandbox Code Playgroud) 我知道你可以在单台和多台机器上敲击GUID生成,并且统计上不太可能两次生成相同的GUID.
互联网上有很多信息可以证明这一点.
对于运行基于.NET Compact Framework 3.5生成GUID的应用程序的100个Windows CE 4,5和6设备,可以说同样的话吗?
我假设是,但找不到任何证明WinCE操作系统使用随机数的信息,并且它们是随机的.
任何人都可以提供此类信息和参考吗?
谢谢,
J.
我想在IIS中部署一个双接口(SOAP/REST/XML/JSON)WCF服务,只有一个配置文件和二进制文件,URL中没有svc文件
我们使用VS2012和.Net 4.5
我们有类似的工作,我在这里跟随指南:http: //blogs.msdn.com/b/rjacobs/archive/2010/04/05/using-system-web-routing-with-data-services-odata的.aspx
我添加了一个Global类
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
DataServiceHostFactory factory = new DataServiceHostFactory();
RouteTable.Routes.Add(new ServiceRoute("wrap", factory, typeof(NeOtheWrapper)));
}
}
Run Code Online (Sandbox Code Playgroud)
我使用现有的web.config来定义所有端点:
<system.serviceModel>
<!-- Clients -->
<client>
<endpoint name="MySoftLive" address="https://backof.somewebsitett.com/Cmp.MySoft.bl/MySoft.svc" binding="basicHttpsBinding" bindingConfiguration="soapSecureBindingConfig" contract="Cmp.MySoft.BL.WCF.MySoftInterface" />
<endpoint name="MySoftTest" address="http://localhost:49957/MySoft.svc" binding="basicHttpBinding" bindingConfiguration="soapBindingConfig" contract="Cmp.MySoft.BL.WCF.MySoftInterface" />
</client>
<!-- Services -->
<services>
<service name="Cmp.MySoft.BL.NeOthe.NeOtheWrapper">
<endpoint name="rest" address="rest" behaviorConfiguration="restEndpointBehaviour" binding="webHttpBinding" bindingConfiguration="restBindingConfig" contract="Cmp.MySoft.BL.NeOthe.INeOtheWrapper"/>
<endpoint name="restSecure" address="rest" behaviorConfiguration="restEndpointBehaviour" binding="webHttpBinding" bindingConfiguration="restSecureBindingConfig" contract="Cmp.MySoft.BL.NeOthe.INeOtheWrapper"/>
<endpoint name="mex" …Run Code Online (Sandbox Code Playgroud) 我已经编写了一些 Windows 批处理文件来为我们的产品包含的所有 VS 解决方案调用 msbuild。
除了一个 SLN 之外,它们都可以工作,其中 CSPROJ 文件会导致问题。
这些项目都是在 VS2008 中构建的。
项目文件夹布局
\RootFolder
\LinqToXsd
-LinqToXsd.targets
-Xml.Schema.Linq.dll
\BL
-BL.csproj
\Config
-Config.csproj
Run Code Online (Sandbox Code Playgroud)
我们已经自定义了 CSPROJ 文件以引入 LinqToXsd:
将此行添加到第一行PropertyGroup:
<LinqToXsdBinDir Condition="'$(LinqToXsdBinDir)' == ''">$(SolutionDir)\..\LinqToXsd</LinqToXsdBinDir>
Run Code Online (Sandbox Code Playgroud)
而在Importfor之后的这一行Microsoft.CSharp.targets
<Import Project="$(LinqToXsdBinDir)\LinqToXsd.targets" />
Run Code Online (Sandbox Code Playgroud)
命令行:
C:\Windows\Microsoft.NET\Framework64\v3.5\msbuild.exe /m /target:Build /nologo /property:BuildInParallel=true;OutDir=E:\Projects\BuildMaster\trunk\built\ConfigTool\;Configuration=Release /verbosity:minimal "*snip*\ConfigTool\ConfigTool.sln"
Run Code Online (Sandbox Code Playgroud)
问题是,我们在输出中得到了这个:
*snip*\ConfigTool\ConfigTool.csproj(131,11): error MSB4019: The imported project "E:\LinqToXsd\LinqToXsd.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
ConfigTool.csproj : Solution …Run Code Online (Sandbox Code Playgroud) 我有一个WCF Web服务,它返回许多不同的对象列表,根据XML Schema格式化.
我有一个简单的winforms测试装置用于触发方法,我可以使用代码中断来使用Quick Watch检查输出.
有没有人知道win form控件可以获取对象并以与Visual Studio相同的方式显示有关它的有用信息?
放在表单上非常方便,因此我可以检查在无法调试的远程站点上运行的已安装服务的输出.
目前,我唯一的选择是编写一个巨大的win表单应用程序,用于单独显示每个响应的内容.
我最好的想法是将响应序列化为XML并将其显示在名为ScintillaNET的语法着色控件中.