'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
sreejithmAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phil DavidsonCommented:
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.
Fareed Ali KhanCommented:
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.
sreejithmAuthor Commented:
Hi Phil.

These were already checked. I tried unchecking. However still the same issue.
ide.JPG
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Fareed Ali KhanCommented:
What are the service configuration?
sreejithmAuthor Commented:
Hi Fareed,

How do I check that ?

Regards
sreejithmAuthor Commented:
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
Fareed Ali KhanCommented:
find the <bindings> section in webservice configuration and write it here with obfuscated values.
sreejithmAuthor Commented:
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>
Fareed Ali KhanCommented:
Write the code here you used to register the TCP Channel and client channel. I need to check the channel registeration.
sreejithmAuthor Commented:
The issue was resolved by re-compiling the webservice in MS Dynamics AX.

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sreejithmAuthor Commented:
The issue was resolved by re-compiling the webservice in AX
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.