我尝试为Entity Framework模型创建WCF数据服务,该模型包含DateTimeOffeset类型的一些属性.但是,WCF数据服务不支持类型DateTimeOffset,因为我在搜索异常文本后发现"类型'Task'上的属性'CreationTime'是'DateTimeOffset'类型,它不是受支持的基本类型.'.请参阅服务器日志有关更多详细信息,异常堆栈跟踪是:...".
我现在正在考虑解决这个问题的不同方法,包括:
将类型更改为可以映射到数据库中的DateTime的内容(最差的解决方案)
将列类型保留为数据库中的DateTimeOffset,将列映射到Entity Framework模型中的两个属性,一个DateTime和另一个类型为integer的"Offset"属性.
我真的不喜欢这些方法.有没有人找到一个很好的解决这个问题的工作?
我正在尝试为wcf客户端实现重新连接逻辑.我知道你必须在当前频道进入故障状态后创建一个新频道.我在一个通道故障事件处理程序中这样做了:
internal class ServiceClient : DuplexClientBase, IServiceClient
{
public ServiceClient(ICallback callback, EndpointAddress serviceAddress)
: base(callback, MyUtility.GetServiceBinding("NetTcpBinding"), serviceAddress)
{
// Open the connection.
Open();
}
public void Register(string clientName)
{
// register to service
}
public void DoSomething()
{
// some code
}
}
public class ClientApp
{
private IServiceClient mServiceClient;
private ICallback mCallback;
public ClientApp()
{
mServiceClient = new ServiceClient( mCallback, new EndpointAddress("someAddress"));
mServiceClient.Register();
// register faulted event for the service client
((ICommunicationObject)mServiceClient).Faulted += new EventHandler(ServiceClient_Faulted);
}
void ServiceClient_Faulted(object sender, …Run Code Online (Sandbox Code Playgroud) 我在项目中使用以下post构建操作,将lib合并到我的应用程序中:
IF $(ConfigurationName) == Debug GOTO end
cp $(TargetPath) $(TargetDir)app_unmerged.exe
del $(TargetPath)
"C:\Program Files\Microsoft\ILMerge\ilmerge.exe" /internalize $(TargetDir)MyApp_unmerged.exe $(TargetDir)someLib.dll /out:$(TargetDir)myApp.exe
del $(TargetDir)myApp_unmerged.exe $(TargetDir)someLib.dll
:end
Run Code Online (Sandbox Code Playgroud)
这很好用.现在我有一个安装程序项目并添加了项目输出.我希望使用"主要输出来源",即/ bin/Release中的exe.但实际上使用的是/bin/release/myApp.exe,而不是/obj/release/myApp.exe.
有谁知道我是否可以更改此行为并使用/ bin/release中的输出作为安装程序项目?谢谢.
考虑使用一个抽象类来派生各种类型的操作(就可以执行的命令而言)。其中一些操作执行异步(如等待、接收),其他操作执行同步(即在 GUI 上显示某些内容)。目前我在基类中只有一个抽象异步方法:
\n\npublic abstract class Action\n{ \n // ...\n\n /// <summary>\n /// Executes the action type specific routines.\n /// </summary>\n protected abstract Task<ActionResult> ExecuteAsync(); \n}\nRun Code Online (Sandbox Code Playgroud)\n\n在派生类的重写中,我使用 TaskCompletionSource 进行同步和异步操作。一方面,我喜欢这样一个事实:从调用者的角度来看,它\xe2\x80\x99 是一个统一的接口。但另一方面,我读到,如果代码实际上是同步的,那么假装是异步的,这是错误的 API 设计。我看到的唯一其他选择是有一个额外的同步
\n\nprotected abstract ActionResult Execute();\nRun Code Online (Sandbox Code Playgroud)\n\n方法和属性
\n\nprotected bool IsAsync { get; };\nRun Code Online (Sandbox Code Playgroud)\n\n决定调用同步或异步方法。但我不喜欢必须处理两种不同方式来执行单个操作的想法。如果并非所有覆盖都是异步的,抽象异步方法是否有最佳实践?
\n