Search code examples
c#wcfxamarinuwpvisual-studio-2017

Xamarin Project works fine in Android, throws "405" errors in UWP when calling WCF


I have an App that works fine when I set Android as the startup project but throws an error when I have UWP as the startup project. I have found, by commenting out code here and there, that the error is occurring when I make a call to my WCF. The second line below is causing the error:

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

The blah error message I can get so far is:

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

Also apparently this was running right before it crashed:

#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)

To further narrow down the cause of this error I created a simple standalone UWP app and I am trying to connect it to a WCF. On this program, I am getting this error message when I make the WCF method call:

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

Any ideas on the cause of this error? Thanks in Advance.


Solution

  • Per @Xavier:

    Changing the settings in the app manifest solved my problem! It was that simple. Thanks.