tukarambande / xmlrpcnet

Automatically exported from code.google.com/p/xmlrpcnet
0 stars 0 forks source link

"Inaccessible interface" exception created when program calls constructor #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public struct DrupalUser
        {
            // Fields
            public string name;
            public string email;
        }

        public struct Drupal
        {
            public string sessionid;
            public DrupalUser user;
        }

        [XmlRpcUrl("http://****.com/drupaltest5/services/xmlrpc")] 
        public interface IServiceSystem : IXmlRpcProxy
        {
            [XmlRpcMethod("system.connect")]
            Drupal Connect();

            [XmlRpcMethod("user.login")]
            Drupal Login(string username, string password);
        }

        /// <summary>
        /// Enter App
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            IServiceSystem iss = XmlRpcProxyGen.Create<IServiceSystem>();
            Drupal cnct = iss.Connect();
            Console.WriteLine(cnct.sessionid);
            Console.ReadLine();

        }

Original issue reported on code.google.com by zacharyd...@gmail.com on 23 Jun 2009 at 11:03

GoogleCodeExporter commented 8 years ago
Unable to reproduce problem.

Original comment by ChasC...@gmail.com on 28 Jul 2009 at 8:47

GoogleCodeExporter commented 8 years ago
i had the same error:

after i changed:
interface IWordTracker

to 
public interface IWordTracker

it works.

Type 'XmlRpcProxy6086f309-83d9-4bf3-8b29-fdb2375e5297' from assembly
'XmlRpcProxy6086f309-83d9-4bf3-8b29-fdb2375e5297, Version=1.0.0.0, 
Culture=neutral,
PublicKeyToken=null' is attempting to implement an inaccessible interface.

here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CookComputing.XmlRpc;
using System.Collections;

namespace XML_RPC_practice
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            IWordTracker WordTracker =
(IWordTracker)XmlRpcProxyGen.Create(typeof(IWordTracker));
            XmlRpcStruct mystruct;    

            try
            {

                if ( WordTracker.ping("guest"))
                {
                    textBox1.Text += "Successfull pinged guest account.";
                 //   .Write("Successfully pinged guest account.");
                }
            }
            catch (Exception Ex)
            {

                textBox1.Text += Ex.Message.ToString();
               //Response.Write(Ex.Message);
            }

        }

        [XmlRpcUrl("http://test.xmlrpc.wordtracker.com")]

        public interface IWordTracker
        {
            [XmlRpcMethod("ping")]
            bool ping(string key);

            [XmlRpcMethod("get_exact_phrase_popularity")]

            XmlRpcStruct get_exact_phrase_popularity(
            string id, 
            string[] key_phrases,  
            string Case,  
            bool include_misspellings,
            bool include_plurals,
            string adult,
            int max,
            int timeout);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            IWordTracker WordTracker =
(IWordTracker)XmlRpcProxyGen.Create(typeof(IWordTracker));
            string[] keyWordArray = { "mp3", "britney spears" };
            XmlRpcStruct mystruct;
            try
            {

                mystruct = WordTracker.get_exact_phrase_popularity(
                        "guest",
                        keyWordArray,
                        "case_distinct",
                        false,
                        true,
                        "exclude_adult",
                        100,
                        10);
                foreach (DictionaryEntry d in mystruct)
                {
                   // Response.Write(d.Key + " : " + d.Value);
                    textBox1.Text += d.Key + " : " + d.Value;
                }

            }
            catch (XmlRpcFaultException fex)
            {
              //  Response.Write("Fault Response: " + fex.FaultCode + " " +
fex.FaultString);
                textBox1.Text += "Fault Response: " + fex.FaultCode + " " +
fex.FaultString;
            }
            catch (Exception Ex)
            {
          //      Response.Write(Ex.Message);

                textBox1.Text += Ex.Message;
            }

        }
    }
}

Original comment by caj...@gmail.com on 16 Oct 2009 at 3:38

GoogleCodeExporter commented 8 years ago
It is worth noting that my original development, which I built under Mono 2.6.1 
on
Mac OS 10.6, did not throw this error, suggesting that Mono is less respectful 
of
class protection levels. However, it did then occur when I compiled under 
VS2008 in
Windows 7, using .NET 3.5. Take note, Mono developers.

Thanks for the information - this issue log saved me a lot of debugging 
headaches.

Original comment by djkit...@gmail.com on 30 Dec 2009 at 5:58

GoogleCodeExporter commented 8 years ago

Original comment by ChasC...@gmail.com on 22 May 2010 at 4:02

GoogleCodeExporter commented 8 years ago
That is strange.
I got this problem too, but after declaring the interface as public the error 
still occurs. What could be the problem?

Original comment by scholz....@googlemail.com on 29 Sep 2011 at 7:39

GoogleCodeExporter commented 8 years ago
It's not working for me in VS2010, even when everything is public.  Could it 
have anything to do with assembly signing?

Original comment by mmcguinn...@webinjected.com on 21 Mar 2012 at 11:43

GoogleCodeExporter commented 8 years ago
I can reproduce this problem when attempting to use the control from a console 
app. Do it from a WinForm and it works fine.

Original comment by dtpe...@gmail.com on 21 Jan 2013 at 8:19

GoogleCodeExporter commented 8 years ago
I'm also having the issue in a console app. Is there a way around this when 
working with a console app?

Original comment by Cody...@gmail.com on 3 Apr 2013 at 3:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
^ Just wanted to update my comment above. ^

In my console app I had a separate class that contained everything for my 
XML-RPC methods, and then I implemented it in program.cs. Although I had made 
the interface public in the xml-rpc class file, I still needed to make the 
class itself public. Then everything worked as planned. (below is a snippet of 
code that reflected this)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CookComputing.XmlRpc;

namespace XmlRpcCmdApp
{
    public class RetrieveOrderStatus
    {
        //Setup an interface that supplies the endpoint, xml-rpc method to call, and the paramters to pass.
        [XmlRpcUrl("http://xml.****.com/xmlAdServer.php")]
        public interface IRetrieveOrder : IXmlRpcProxy
        {
            [XmlRpcMethod("immediate.retrieve_order_status")]
            XmlRpcStruct immediate_retrieve_order_status(String UserName,
                                                         String Password,
                                                         Int32 ManufacturerID,
                                                         Int32 CatalogID,

                                                         RequestDetailsStruct RequestDetails);
        }

Original comment by Cody...@gmail.com on 3 Apr 2013 at 3:31