什么是由Visual Studio中的"创建服务引用"自动生成的.datasource文件?文件中的注释是这样的:
此文件由Visual Studio .Net自动生成.它用于存储通用对象数据源配置信息.
重命名文件扩展名或编辑此文件的内容可能
导致该程序无法识别该文件.
但是,听起来这些文件是可选的,所以我想知道它们用于什么.我也想知道删除它们是否真的安全,因为它们经常导致XP上的路径长度问题.
http://www.eggheadcafe.com/conversation.aspx?messageid=34104031&threadid=34104026
谁能指点我这些文件的官方MS文档?
我在我的解决方案中创建了一个WCF服务库项目,并提供了对此的服务引用.我使用类库中的服务,所以除了类库之外,我还有来自WPF应用程序项目的引用.服务直接设置 - 仅更改为获取异步服务功能.
一切都很好 - 直到我想更新我的服务参考.它失败了,所以我最终回滚并重试,但即便如此也失败了!因此 - 更新服务引用失败而不对其进行任何更改.为什么?!
我得到的错误就是这个:
Custom tool error: Failed to generate code for the service reference
'MyServiceReference'. Please check other error and warning messages for details.
Run Code Online (Sandbox Code Playgroud)
警告提供了更多信息:
Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: List of referenced types contains more than one type with data contract name 'Patient' in
namespace 'http://schemas.datacontract.org/2004/07/MyApp.Model'. Need to exclude all but one of the
following types. Only matching types …Run Code Online (Sandbox Code Playgroud) 在我的silverlight应用程序中,我正在尝试使用LINQ创建数据库连接.首先,我添加一个新的LINQ to SQL类,并将名为"tblPersoon"的表拖入其中.
然后在我的服务文件中,我尝试执行以下查询:
[OperationContract]
public tblPersoon GetPersoonByID(string id)
{
var query = (from p in tblPersoon where p.id == id select p).Single();
Run Code Online (Sandbox Code Playgroud)
但是在tblPersoon它给了我以下错误.
无法找到源类型"SilverlightApplication1.Web.tblPersoon"的查询模式的实现.'哪里'找不到.
即使我尝试以下内容:
var query = (from p in tblPersoon select p).Single();
Run Code Online (Sandbox Code Playgroud)
它给我一个错误,说'找不到'!
我的表的生成类的代码可以在这里找到:http://pastebin.com/edx3XRhi
造成这种情况的原因是什么,我怎么能解决这个问题?
谢谢.
只是想知道在什么情况下,当您可以使用ChannelFactory调用调用时,您更愿意从WCF服务生成代理?
这样,您不必生成代理,并担心在服务器更新时重新生成代理?
谢谢
我的本地计算机上运行的WCF服务正常运行.我把它放在服务器上,我收到以下错误:
接收到http://xx.xx.x.xx:8200/Services/WCFClient.svc的HTTP响应时发生错误 .这可能是由于服务端点绑定不使用HTTP协议.这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭).有关详细信息,请参阅服务器日志.
我已经去了url中的服务,它正常工作.我正在为函数做的就是将一个字符串返回到一个图像名称,因此传递的数据不是很多.我已经跟踪了日志,它给了我相同的信息.这是我的客户端配置:
<binding name="basicHttpBinding_IWCFClient" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<endpoint name="basicHttpBinding_IWCFClient"
address="http://localhost:4295/Services/WCFClient.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_IWCFClient"
behaviorConfiguration="WCFGraphicManagementTool.Services.ClientBehavior"
contract="WCFClient.IWCFClient" />
Run Code Online (Sandbox Code Playgroud)
这是我的服务器配置:
<service behaviorConfiguration="WCFGraphicManagementTool.Services.WCFClientBehavior"
name="WCFGraphicManagementTool.Services.WCFClient">
<endpoint name="basicHttpBinding_IWCFClient"
address=""
binding="basicHttpBinding"
contract="WCFGraphicManagementTool.Contracts.IWCFClient" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
<behavior name="WCFGraphicManagementTool.Services.WCFClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceThrottling maxConcurrentCalls="120" maxConcurrentSessions="120"
maxConcurrentInstances="120" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" /> …Run Code Online (Sandbox Code Playgroud) 我使用这个方法时遇到了问题 X509Store.Certificates.Find
public static X509Certificate2 FromStore(StoreName storeName,
StoreLocation storeLocation, X509FindType findType, string findValue)
{
X509Store store = new X509Store(storeName, storeLocation);
store.Open(OpenFlags.ReadOnly);
try
{
//findValue = "7a6fa503ab57b81d6318a51ca265e739a51ce660"
var results = store.Certificates.Find(findType, findValue, true);
return results[0];
}
finally
{
store.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,Find方法返回0 results(results.Count == 0),但如果我将findValue作为常量,则该方法会找到证书.
public static X509Certificate2 FromStore(StoreName storeName,
StoreLocation storeLocation, X509FindType findType, string findValue)
{
X509Store store = new X509Store(storeName, storeLocation);
store.Open(OpenFlags.ReadOnly);
try
{
//findValue= "7a6fa503ab57b81d6318a51ca265e739a51ce660"
var results = store.Certificates.Find(findType,
"7a6fa503ab57b81d6318a51ca265e739a51ce660", true);
return results[0];
}
finally
{ …Run Code Online (Sandbox Code Playgroud) 我的WCF服务可以从代码的第一个模型回归类的唯一方法是通过设置ProxyCreationEnable来false使用下面的代码.
((IObjectContextAdapter)MyDb).ObjectContext.ContextOptions.ProxyCreationEnable = false;
Run Code Online (Sandbox Code Playgroud)
这样做的负面后果是什么?一个好处是我至少可以将这些动态类型序列化,以便可以使用WCF通过线路发送它们.
WCF反序列化有一些神奇之处.如何在不调用其构造函数的情况下实例化数据协定类型的实例?
例如,考虑这个数据合同:
[DataContract]
public sealed class CreateMe
{
[DataMember] private readonly string _name;
[DataMember] private readonly int _age;
private readonly bool _wasConstructorCalled;
public CreateMe()
{
_wasConstructorCalled = true;
}
// ... other members here
}
Run Code Online (Sandbox Code Playgroud)
通过DataContractSerializer您获取此对象的实例时,您将看到该字段_wasConstructorCalled是false.
那么,WCF如何做到这一点?这是其他人可以使用的技术,还是隐藏在我们之外?
我正在尝试连接到一个api,它从WCF服务(WCF服务到WCF服务)返回GZip编码的JSON.我正在使用HTTPClient连接到API,并且能够将JSON对象作为字符串返回.但是我需要能够将这些返回的数据存储在数据库中,因此我认为最好的方法是将JSON对象返回并存储在数组或字节中或沿着这些行存储.
我特别遇到的问题是GZip编码的解压缩,并且尝试了很多不同的例子,但仍然无法得到它.
下面的代码是我建立连接和获得响应的方式,这是从API返回字符串的代码.
Run Code Online (Sandbox Code Playgroud)public string getData(string foo) { string url = ""; HttpClient client = new HttpClient(); HttpResponseMessage response; string responseJsonContent; try { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); response = client.GetAsync(url + foo).Result; responseJsonContent = response.Content.ReadAsStringAsync().Result; return responseJsonContent; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return ""; } }
我一直在关注一些不同的例子,比如这些StackExchange API,MSDN和一些关于stackoverflow,但我无法让任何这些对我有用.
实现这一目标的最佳方法是什么,我是否在正确的轨道上?
多谢你们.
wcf ×10
c# ×5
.net ×1
certificate ×1
datasource ×1
file ×1
gzip ×1
json ×1
linq ×1
net.tcp ×1
proxy ×1
reflection ×1
silverlight ×1
sql ×1
wcf-binding ×1
wcf-endpoint ×1
wpf ×1