- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在尝试创建一个可以通过 WCF 从其他正在运行的应用程序接收信息的应用程序。我在单独的类中设置了一个 void 方法,创建了接口(interface),并托管了服务。
在我的主机应用程序中,我有以下方法。
public Class ReceivingMethods : IReceivingMethods
{
Public void HelloWorld(string text)
{
MessageBox.Show(text);
}
}
和
[ServiceContract]
interface iReceivingMethods
{
[OperationContract]
void HelloWorld(string text);
}
在客户端,我想这样做:
HostService client = new HostService();
client.HelloWorld("Hello World");
client.close();
但它不起作用,我必须这样做。
HostService client = new HostService();
HelloWorld hi = new HelloWorld();
hi.text = "Hello World";
client.HelloWorld(hi);
client.close();
我已经让它像以前一样在应用程序/ASP 组合中工作,但在这个应用程序中没有,我找不到两个应用程序之间的设置有任何区别。
谁能告诉我 WCF 设置需要什么才能让它像前者一样工作?
最佳答案
HostService client = new HostService();
您没有提到要使用哪个端点或哪个类对象。通常,服务主机类必须创建特定端点的对象,如下所示。
using(System.ServiceModel.ServiceHost host =
new System.ServiceModel.ServiceHost(typeof(ReceivingMethodsnamespace.ReceivingMethods )))
{
host.Open();
Console.WriteLine("Host started @ " + DateTime.Now.ToString());
Console.ReadLine();
}
通常主机服务必须创建一个实现服务契约(Contract)接口(interface)的类的对象(地址绑定(bind)契约(Contract)文件的服务名称)
关于托管应用程序中的 C# 方法,在客户端应用程序中变成类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46081978/
我已经阅读了这个答案https://stackoverflow.com/a/45486495/1108891 ,它演示了元组类型推断。经过一些实验,我遇到了这种情况。 当我们的 tuple 函数有 T
我想删除零, 我喜欢这个模型,如果我输入 1000 然后额外的表显示从 1 到 1000 的所有数字,每个数字都会检查并删除零。 示例:如果我输入 10然后输出如 1 2 3 .....8 9 1(1
鉴于我对PowerShell的了解仍在开发中,请与我一起提出任何建议/答案。 因此,在我工作的地方我们工作的公司拥有大量日文机器,需要注册Intune。但是,我们正在运行的脚本无法在其计算机上运行,
我刚刚制作了一个将路径保存到 INI 文件中的小程序。 但是在输出中,路径是这样写的: C:\\Windows 我想这样写: C:\Windows 我用 string.replace 尝试了很多方法,
所以我尝试 std::replace(diff_path.begin(), diff_path.end(), "\\", "/"); 但它似乎无法在我的 Visual Studio 上编译.怎么办 -
我使用以下代码每 30 秒自动抓取/设置最新的页面标题: setInterval(function() { var data = "http://mysite.com/mypage
我希望有两个 View 是组成集的一部分。每个 View 中的数据最好在 UITableView 中表示。然后,我想添加一个手势来使 View 在屏幕上闪烁,并引入另一个类似的 View ,并带有页面
我正在尝试开发一个小游戏,但我遇到了以下问题:我有一个伪类“Cannon”,每个 Cannon 都有一个存储它应该守卫的区域的数组和一个存储“入侵者”的数组进入其中一个戒备区。我创建了下一个函数作为
当我从应用程序中进行插入时,所有 ★(星号)都会变成“â…” 如何阻止这种情况发生? *如果我直接通过 phpmyadmin 插入它,它就可以工作,但使用这个 php 时则不行: connect_er
我遇到了一个奇怪的问题,将 NSDictionary 存储到 NSUserDefaults,然后检索它会将其转换为 NSCFString。 这是我保存数据的地方: - (void)saveProgre
我正在尝试像这样向 coinbase api 发出请求 $url = "https://api.gdax.com/products/BTC-USD/candles?start=".date($form
我在 HTTP header 中使用 if-modified-since 来决定是否应该下载文件。应用程序已经过测试,一切正常,但现在当我询问我的 NSHTTPURLResponse 实例 respo
我向串口发送0xFF 结果是 0x3F。 所有其他字节都是正确的。 情况是这样的…… 外部盒子将这些字节发送到 PC... 0xFF, 0x0D, 0x00, 0x30, 0x31, 0x53, 0x
所以我在我的 Next JS 应用程序中遇到了这个奇怪的问题,我导入了谷歌字体,如下所示 在我的浏览器中显示的不是 href,而是 data-href="...",所以问题是谷歌无法将此识别为链接
我试图通过将 QRect 变成 QPolygon 来检查 QPolygon 和 QRect 之间的碰撞。但是,矩形也可能有我添加的旋转,所以我想知道如何将 QRect 变成 QPolygon 并考虑到
我正在尝试写一个 Conduit使用 attoparsec解析器。具体来说,给定 parseOne :: Parser T , 我想构建一个 Conduit ByteString m T重复地将解析器
标记内的超链接
我正在尝试添加 和 所以实际的文字出现在我的页面上。不是链接。 所以我希望在我的页面上显示实际的 HTML,如下所示: 目前,出现了一个死图像...我想 单独阻止了这一点,只是显示了普通的html?
最近发现一些路由器设备包含后门,some of which可以通过单个UDP数据包加以利用。我意识到其中一些后门不一定是恶意的,因为我在自己的产品中也做了同样的事情以进行故障排除:打开套接字将心跳数据
我知道我可以将 iOS 设备变成 iBeacons ( Can an iOS7 device act as an iBeacon? )。不幸的是,我只有一台设备,我的信标还没有到达。所以我想知道如何将
有没有人尝试过将 MAC 变成 iBeacon。我已经为 iOS 设备完成了此操作,并且想要一个类似的带有一些 UI 的 MAC 独立应用程序。我听说 Mavericks 上的新 API 支持 iBe
我是一名优秀的程序员,十分优秀!