Xamarin Project在Android中工作正常,调用WCF时在UWP中引发“ 405”错误

时间:2018-08-10 00:28:11

标签: c# wcf xamarin uwp visual-studio-2017

我有一个应用程序,当我将Android设置为启动项目时运行良好,但是当我将UWP作为启动项目时抛出错误。通过在此处和此处注释掉代码,我发现在我调用WCF时发生了错误。下面的第二行导致错误:

        _client = new Service1Client(binding, Endpoint);
        var result = _client.CreateUser(Txt_UserName.Text , Txt_Password.Text);

到目前为止,我收到的错误消息是:

Unhandled exception at 0x0878DC3C (Windows.UI.Xaml.dll) in MyApp.UWP.exe: 
0xC000027B: An application-internal exception has occurred (parameters: 
0x172E2738, 0x00000006). occurred

显然,它在崩溃之前就已经在运行:

#define BEGIN_DELEGATE_MAP(CLASS)\
    ref class delegate_proxy_type;\
    msclr::delegate_map::internal::delegate_proxy_factory<CLASS> m_delegate_map_proxy;\
    \
    ref class delegate_proxy_type\
    {\
            CLASS* m_p_native_target;\
    public:\
            delegate_proxy_type(CLASS* pNativeTarget) : m_p_native_target(pNativeTarget) {}\
            void detach() { m_p_native_target = NULL; }

#define EVENT_DELEGATE_ENTRY(MEMBER,ARG0,ARG1)\
    void MEMBER(ARG0 arg0,ARG1 arg1)\
    {\
            if(m_p_native_target == NULL)\
            throw gcnew System::ArgumentNullException("Delegate call failed: Native sink was not attached or has already detached from the managed proxy (m_p_native_target == NULL). Hint: see if native sink was destructed or not constructed properly");\
            \
            m_p_native_target->MEMBER(arg0,arg1);\
    }

#define END_DELEGATE_MAP()\
    };

#define MAKE_DELEGATE(DELEGATE,MEMBER)\
    gcnew DELEGATE(m_delegate_map_proxy.get_proxy(this),&delegate_proxy_type::MEMBER)

为进一步缩小此错误的原因,我创建了一个简单的独立UWP应用,并尝试将其连接到WCF。在此程序上,当我进行WCF方法调用时,我收到此错误消息:

 'The remote server returned an unexpected response: (405) Method Not Allowed.'

关于此错误原因的任何想法?预先感谢。

1 个答案:

答案 0 :(得分:0)

每个@Xavier:

更改应用清单中的设置可以解决我的问题!就这么简单。谢谢。