Я пытаюсь подключить excel к сервису WCF, но я не могу получить даже тривиальный случай для работы ... Я получаю ошибку Invalid Syntax когда я пытаюсь создать прокси-сервер в excel. Я приложил отладчик визуальной студии, чтобы преуспеть, и получим, что реальная ошибка «интерфейс не найден». Я знаю, что сервис работает, потому что тестовый клиент, созданный визуальной студией, в порядке ... поэтому проблема заключается в строке прошивки VBA.«интерфейс не найден» в WCF Moniker без регистрации для excel
Я надеюсь найти одну из двух вещей:
1) поправки к моему прозвищу строке, которая будет делать эту работу, или
2) существующий пример проект для загрузки, который имеет источник как для хоста, так и для клиента, который работает.
Вот код для моего клиента VBA:
Dim addr As String
addr = "service:mexAddress=net.tcp://localhost:7891/Test/WcfService1/Service1/mex, "
addr = addr + "address=net.tcp://localhost:7891/Test/WcfService1/Service1/, "
addr = addr + "contract=IService1, contractNamespace=http://tempuri.org, "
addr = addr + "binding=NetTcpBinding_IService1, bindingNamespace=""http://tempuri.org"""
MsgBox (addr)
Dim service1 As Object
Set service1 = GetObject(addr)
MsgBox service1.Test(12)
У меня есть следующие услуги:
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
Он имеет следующий конфигурационный файл:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="WcfService1.Service1Behavior"
name="WcfService1.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="WcfService1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7891/Test/WcfService1/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Редактировать:
Обновленный кличка, который работал для меня следующим образом
Dim addr As String
addr = "service:mexAddress=""net.tcp://localhost:7891/Test/WcfService1/Service1/Mex"", "
addr = addr + "address=""net.tcp://localhost:7891/Test/WcfService1/Service1/"", "
addr = addr + "contract=""IService1"", contractNamespace=""http://tempuri.org/"", "
addr = addr + "binding=""NetTcpBinding_IService1"", bindingNamespace=""http://tempuri.org/"""
Такая же ошибка также возникает, когда служба WCF предоставляет методы с не примитивными типами в качестве параметров или возвращаемых типов. – ssgonell