[SOLVED] "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
ThibTib
Posts: 16
Joined: Tue May 31, 2016 10:34 am

[SOLVED] "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Postby ThibTib » Sun Aug 28, 2016 5:55 am

Hi,

as said in the subject, I get an error when calling my WCF service (which works well on the simulator).

Here is the creation of the client :

Code: Select all

class ServiceClientSingleton
    {
        private static ServiceClient _client;
        static readonly object _lock = new object();

        private static ServiceClient ServiceClientSingleton()
        {
            _client = new ServiceClient(new System.ServiceModel.BasicHttpBinding(),
            new System.ServiceModel.EndpointAddress(new Uri(@"http://localhost:2457/Service.svc/Service.svc")));
            return _client;
        }

        public static ServiceClient Client()
        {
            if (_client == null)
            {
                lock (_lock)
                {
                    if (_client == null)
                        ServiceClientSingleton();
                }
            }

            return _client;
        }
    }


-- By the way I don't know why I had to put this weird URL with /Service.svc/Service.svc to make it work.. --

Here is how I call my webMethod :

Code: Select all

_listOfCategories = ServiceClientSingleton.Client().GetCategories().ToList();


And finally the code of the WebMethod :

Code: Select all

List<Categorie> IService.GetCategories()
        {
            List<Categorie> result = new List<Categorie>();

            foreach (CATEGORIE DBCategorie in GetCategories())
            {
                result.Add(new Categorie { Code = DBCategorie.CATEGORIE_CODE, Libelle = DBCategorie.CATEGORIE_LIBELLE });
            }

            return result;
        }
...

private List<CATEGORIE> GetCategories()
        {
            return Model.CATEGORIE.ToList();
        }
       


CATEGORIE is in uppercase because it's a class generated by EntityFramework.

To be complete, my web.config (client):

Code: Select all

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:2457/Service.svc/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                contract="Service.IService" name="BasicHttpBinding_IService" />
        </client>
    </system.serviceModel>



Another thing to say is when I follow the tutorial making a global.asax file and putting the code to the "beginrequest" method, I get an error and my wcf test client refuse to work. So in server side I haven't any global.asax file.

What am I making wrong ?

Thanks in advance and good job for the new beta.
Last edited by ThibTib on Thu Sep 01, 2016 3:46 am, edited 1 time in total.
--
ThibTib

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Postby JS-Support @Userware » Mon Aug 29, 2016 4:24 am

Hi,

I guess you have followed the recommendations described at:
http://www.cshtml5.com/links/wcf-limitations-and-tutorials.aspx

Can you please double-check that, on the server side, the [XmlSerializerFormat] is present on all the classes that have the [ServiceContract] attribute? (if not, after adding it, please be sure to update the service reference on the client).

Thanks.
Regards,
JS-Support

ThibTib
Posts: 16
Joined: Tue May 31, 2016 10:34 am

Re: "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Postby ThibTib » Mon Aug 29, 2016 12:03 pm

Hi and thx for you reactivity !

Yes I've put

Code: Select all

[XmlSerializerFormat]
to my interface (I had put to my class directly, it does not work).
First step is done :)

So now I have a new problem.

I must explain to you that my WCFService returns objects which are from an other dll - an empty class library (C#/XAML for HTML5) - which is referenced in my WCFService server and in my C#/XAML for HTML5 App. But it looks like it cannot work like that, because here is my error (translated from french) :

Code: Select all

To be XML serializable, types that inherit from IEnumerable must have an implementation of Add ( System.Object ) ... at all levels of their inheritance hierarchy . System.Collections.Generic.HashSet2`1[[System.Collections.Generic.KeyValuePair`2[[Windows.UI.Xaml.DependencyObject, CSharpXamlForHtml5 , Version = 1.0.0.0 , Culture = neutral, PublicKeyToken = null ], [ Windows.UI.Xaml.DependencyProperty , CSharpXamlForHtml5 , Version = 1.0.0.0 , Culture = neutral, PublicKeyToken = null ]] , mscorlib , Version = 4.0. 0.0 , Culture = neutral, PublicKeyToken = b77a5c561934e089 ]] does not implement Add ( System.Object ) .


In the tutorial, objects that are returned from the WCFService are directly declared inside the WCF project, there are no empty class library CSHTML5 used.
Do I have to declare them like that and remove my intermediate project, my dll of objects ?

thx in advance for your reply.

ThibTib
--
ThibTib

ThibTib
Posts: 16
Joined: Tue May 31, 2016 10:34 am

Re: "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Postby ThibTib » Thu Sep 01, 2016 3:45 am

I finally found the solution :
Do not create a separate project containing objects which are sent by the Webservice : it will force you to use a CSHTML5 dll (have to be to be referenced by your app) and it's not compatible with a WCF response flux.

You must declare classic .Net classes directly inside the WCF project and reference them in your app, via a specific namespace for example : WCFService.Entities.

I suggest the team to specify it in the tutorial.
--
ThibTib

Henrygo
Posts: 8
Joined: Thu Nov 24, 2016 10:42 pm

Re: [SOLVED] "System.Runtime.CompilerServices.CallSite '1 has not been defined" error

Postby Henrygo » Mon Dec 12, 2016 6:20 pm

Hi ThibTib

I hava the same problem,but can not understand what you provided solution.
Can you give me an example to explain exactly?
Thank you very much!


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 44 guests

 

 

cron