Link to home
Start Free TrialLog in
Avatar of sreejithm
sreejithm

asked on

'System.ServiceModel.FaultException`1' occurred in mscorlib.dll Error C#

Good Morning.

As a part of my ongoing project for an in house integration, I need to push some data into our MS Dynamic CRM erp from a custom application.  My code was working fine until yesterday, when I started getting the error :

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll

I am calling a webservice from a C# windows client.

My code is as below

private void button1_Click(object sender, EventArgs e)
        {
            testAX.TelephoneRevenueClient tel = new testAX.TelephoneRevenueClient();
            testAX.Alle_TelephoneRevenueData rev = new testAX.Alle_TelephoneRevenueData();

            tel.ClientCredentials.Windows.ClientCredential.Domain = "dddd";
            tel.ClientCredentials.Windows.ClientCredential.UserName = "testuser";
            tel.ClientCredentials.Windows.ClientCredential.Password = "mtestpassword";

            tel.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

            DateTime dt1 = new DateTime(2015, 05, 01);
            DateTime dt2 = new DateTime(2015, 05, 28);

            rev.parmAcctNum = "045013771";
            rev.parmCustAccount = "500725";
            rev.parmDepartment = "015";
            rev.parmLOB = "010";
            rev.parmPeriod = "201405";

            //rev.parmRevFixed = Convert.ToDecimal(pfRev);
            //rev.parmRevUsage = Convert.ToDecimal(puRev);

            rev.parmSDate = dt1;
            rev.parmEDate = dt2;

            tel.insertRevenue(new testAX.CallContext(), rev);

            Console.WriteLine("done");
            Console.Read();
        }

Open in new window


Could you please asssist
Avatar of Phil Davidson
Phil Davidson
Flag of United States of America image

In Visual Studios, do you have debugging enabled for exception assistant and "Just My Code (Managed Only)"?

In Visual Studios, go to Tools -> Options (of the Integrated Development Environment):

Enable the exception assistant,
Enable Just My Code (Managed Only)

If the above are unchecked, I don't know what the problem is.  But based on your description (with the problem rearing its head upon a client connecting), I bet the above are checked.  You could try unchecking them and see if the problem goes away.
Disabling the error option in the Visual Studio Editor Tools->Option menu of IDE

- Uncheck  Visual Studio Editor Tools -> Option -> Debugging -> General -> Enable the exception assistant.
- Uncheck  Visual Studio Editor Tools -> Option -> Debugging -> General -> Enable just my code.

After that you will get the actual error which was throw by web service instead of FaultException.
Avatar of sreejithm
sreejithm

ASKER

Hi Phil.

These were already checked. I tried unchecking. However still the same issue.
ide.JPG
What are the service configuration?
Hi Fareed,

How do I check that ?

Regards
Hi Fareed.

Please find the detailed exception below


Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at testservice.testAX.TelephoneRevenue.insertRevenue(TelephoneRevenueInsertRevenueRequest request)
   at testservice.testAX.TelephoneRevenueClient.testservice.testAX.TelephoneRevenue.insertRevenue(TelephoneRevenueInsertRevenueRequest request) in c:\Users\Sree\Documents\Visual Studio 2013\Projects\testservice\testservice\Service References\testAX\Reference.cs:line 861
   at testservice.testAX.TelephoneRevenueClient.insertRevenue(CallContext CallContext, Alle_TelephoneRevenueData _telRevenue) in c:\Users\Sree\Documents\Visual Studio 2013\Projects\testservice\testservice\Service References\testAX\Reference.cs:line 868
   at testservice.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\Sree\Documents\Visual Studio 2013\Projects\testservice\testservice\Form1.cs:line 48
done
find the <bindings> section in webservice configuration and write it here with obfuscated values.
Hi Fareed.

<system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_TelephoneRevenue" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://test12314:8202/DynamicsAx/Services/TeleRevenue"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_TelephoneRevenue"
                contract="testAX.TelephoneRevenue" name="NetTcpBinding_TelephoneRevenue">
                <identity>
                    <userPrincipalName value="test@test.loc" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
Write the code here you used to register the TCP Channel and client channel. I need to check the channel registeration.
ASKER CERTIFIED SOLUTION
Avatar of sreejithm
sreejithm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The issue was resolved by re-compiling the webservice in AX