Click here to Skip to main content
15,919,245 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Index was outside the bound of the array error after deployment Pin
Luc Pattyn1-Aug-07 23:17
sitebuilderLuc Pattyn1-Aug-07 23:17 
AnswerRe: Index was outside the bound of the array error after deployment Pin
originSH2-Aug-07 3:06
originSH2-Aug-07 3:06 
JokeRe: Index was outside the bound of the array error after deployment Pin
Luc Pattyn2-Aug-07 6:18
sitebuilderLuc Pattyn2-Aug-07 6:18 
GeneralRe: Index was outside the bound of the array error after deployment Pin
Pete O'Hanlon2-Aug-07 10:24
mvePete O'Hanlon2-Aug-07 10:24 
GeneralRe: Index was outside the bound of the array error after deployment Pin
originSH2-Aug-07 22:26
originSH2-Aug-07 22:26 
Questionhow can i define the setup serial number? Pin
Wan--Vevi1-Aug-07 21:40
Wan--Vevi1-Aug-07 21:40 
Questionhi Pin
dhanu1231-Aug-07 21:40
dhanu1231-Aug-07 21:40 
QuestionRemoting - Code not executing after an Activator object call Pin
Jigzaw1-Aug-07 6:05
Jigzaw1-Aug-07 6:05 
Hello everyone,

I am working on an application that uses .NET Remoting to communicate between a Windows Service and a client program. I am trying to use Activator.GetObject from the service to access data in the remoting server. Unfortunately, the service reaches the code where I request the data from the remoting server and never gets past it. The code after that line is never executed and an exception is never caught. I can't figure out what I'm doing wrong.

The code is below. Any help or suggestions would be greatly appreciated.

Jason Lewis

<br />
Remoting Object<br />
---------------<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Contexts;<br />
<br />
namespace MCCSharedLib<br />
{<br />
    [Serializable()]<br />
    public class OutData<br />
    {<br />
        /*-------------------------------------------------*/<br />
        [Serializable()]<br />
        public struct OutItems<br />
        {<br />
            public int iNumUnits;<br />
            public int iAType;<br />
            public int iBType;<br />
	    ...	<br />
            public bool bAAdvanced;<br />
            public bool bBAdvanced;<br />
        };<br />
<br />
        public OutItems m_OutItems;<br />
        /*-------------------------------------------------*/<br />
        public OutItems OutputItems<br />
        {<br />
            get { return m_OutItems; }<br />
            set { m_OutItems = value; }<br />
        }<br />
        /*-------------------------------------------------*/<br />
        public OutData()<br />
        {<br />
            // Initialize the OutItems struct.<br />
            m_OutItems = new OutItems();<br />
            m_OutItems.iNumUnits = 1;<br />
            m_OutItems.iAType = 2;<br />
            m_OutItems.iBType = 2;<br />
            ...<br />
            m_OutItems.bAAdvanced = false;<br />
            m_OutItems.bBAdvanced = false;<br />
        }<br />
        /*-------------------------------------------------*/<br />
    }<br />
}<br />
<br />
ILoadMenu Interface<br />
-------------------<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
using MCCSharedLib;<br />
<br />
namespace MCCRemoteClient<br />
{<br />
    public interface IGetData<br />
    {<br />
        /*-------------------------------------------------*/<br />
        InData GetData();<br />
        /*-------------------------------------------------*/<br />
    }<br />
<br />
    public interface ISetData<br />
    {<br />
        /*-------------------------------------------------*/<br />
        void SetData(MCCSharedLib.OutData.OutItems _OutData);<br />
        /*-------------------------------------------------*/<br />
    }<br />
}<br />
<br />
Server<br />
------<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Tcp;<br />
using System.Text;<br />
<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Threading;<br />
using System.Diagnostics;<br />
using System.Runtime.InteropServices;<br />
using Microsoft.Win32;<br />
<br />
using MCCRemoteClient;<br />
using MCCSharedLib;<br />
<br />
<br />
namespace MCCRemoteServer<br />
{<br />
    public class MenuManager : MarshalByRefObject, IGetData, ISetData<br />
    {<br />
        private System.Threading.Timer m_HIDTimer;<br />
        private MCCSharedLib.OutData m_OutItems;<br />
<br />
        public MenuManager()<br />
        {<br />
            m_OutItems = new OutData();<br />
<br />
            // Set up the timer<br />
            TimerCallback timerDelegate = new TimerCallback(UpdateData);<br />
            m_HIDTimer = new Timer(timerDelegate, null, 1000, 1000);<br />
        }<br />
<br />
        public override Object InitializeLifetimeService()<br />
        {<br />
            return null;<br />
        }<br />
<br />
        private void UpdateData(object state)<br />
        {<br />
            ... (works fine)<br />
        }<br />
<br />
        /*-------------------------------------------------*/<br />
        // This method implements the ILoadMenu interface.<br />
        public MCCSharedLib.InData GetData()<br />
        {<br />
            return m_DataItems;<br />
        }<br />
<br />
        public void SetData(MCCSharedLib.OutData.OutItems _OutData)<br />
        {<br />
            m_OutItems.OutputItems = _OutData;<br />
<br />
        }<br />
<br />
        /*-------------------------------------------------*/<br />
        public MCCSharedLib.OutData.OutItems GetOutData()<br />
        {<br />
            OutData.OutItems TempData = new OutData.OutItems();<br />
<br />
            TempData = m_OutItems.m_OutItems;<br />
<br />
            return TempData;<br />
        }<br />
    }<br />
}<br />
<br />
Windows Service<br />
---------------<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Diagnostics;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Tcp;<br />
using System.ServiceProcess;<br />
using System.Text;<br />
using System.Threading;<br />
using System.Runtime.InteropServices;<br />
<br />
using MCCRemoteServer;<br />
using MCCRemoteClient;<br />
using MCCSharedLib;<br />
<br />
namespace MCCRemoteService<br />
{<br />
    public partial class MCCRemoteService : ServiceBase<br />
    {<br />
        private MCCSharedLib.OutData.OutItems m_OutItems;<br />
        private System.Threading.Timer m_HIDTimer;<br />
<br />
        /*-------------------------------------------------*/<br />
        public MCCRemoteService()<br />
        {<br />
            m_OutItems = new OutData.OutItems();<br />
<br />
            InitializeComponent();<br />
<br />
            // Set up the timer<br />
            TimerCallback timerDelegate = new TimerCallback(UpdateData);<br />
            m_HIDTimer = new Timer(timerDelegate, null, 1000, 1000);<br />
        }<br />
<br />
        private void UpdateData(object state)<br />
        {<br />
            MCCSharedLib.OutData.OutItems OutItems;<br />
<br />
            MenuManager RemoteObj = (MenuManager)Activator.GetObject(typeof(MenuManager), "http://localhost:9250/RemoteObject");<br />
<br />
            try<br />
            {<br />
                // Update the output information ------------------------------<br />
                OutItems = RemoteObj.GetOutData();   ******************** Line in question *******************<br />
<br />
                ... (more code, never reached)<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
            }<br />
        }<br />
        /*-------------------------------------------------*/<br />
        protected override void OnStart(string[] args)<br />
        {<br />
            TcpServerChannel channel;<br />
<br />
            // Register the TCP channel<br />
            channel = new TcpServerChannel(9250);<br />
<br />
            // Register our channel.<br />
            ChannelServices.RegisterChannel(channel, true);<br />
<br />
            // Set up the object binding and behavior.<br />
            RemotingConfiguration.RegisterWellKnownServiceType<br />
                        (typeof(MenuManager), "MenuManager", <br />
                        WellKnownObjectMode.Singleton);<br />
        }<br />
    }<br />
}<br />

QuestionRemoting loses subscription but not proxy Pin
John Whitmire1-Aug-07 5:59
professionalJohn Whitmire1-Aug-07 5:59 
AnswerRe: Remoting loses subscription but not proxy Pin
John Whitmire2-Nov-07 4:16
professionalJohn Whitmire2-Nov-07 4:16 
Question[Setup Project] run a file by condition Pin
hamid_m1-Aug-07 2:50
hamid_m1-Aug-07 2:50 
GeneralRe: [Setup Project] run a file by condition Pin
Ilya Verbitskiy1-Aug-07 4:32
Ilya Verbitskiy1-Aug-07 4:32 
GeneralRe: [Setup Project] run a file by condition Pin
hamid_m2-Aug-07 3:34
hamid_m2-Aug-07 3:34 
Questionadd files and folder to publish (win app) Pin
hamid_m1-Aug-07 2:47
hamid_m1-Aug-07 2:47 
AnswerRe: add files and folder to publish (win app) Pin
kubben2-Aug-07 2:51
kubben2-Aug-07 2:51 
GeneralRe: add files and folder to publish (win app) Pin
hamid_m2-Aug-07 3:33
hamid_m2-Aug-07 3:33 
QuestionTreeView layout question [modified] Pin
adt_brauer31-Jul-07 2:22
adt_brauer31-Jul-07 2:22 
QuestionAPI lock(Disable) Mouse Pin
sharmie31-Jul-07 0:49
sharmie31-Jul-07 0:49 
AnswerRe: API lock(Disable) Mouse Pin
Paul Conrad12-Aug-07 6:39
professionalPaul Conrad12-Aug-07 6:39 
Questionexpandable gridview Pin
Sallu174930-Jul-07 19:18
Sallu174930-Jul-07 19:18 
QuestionUnable to connect to any specified mysql hosts Pin
boyindie30-Jul-07 13:44
boyindie30-Jul-07 13:44 
AnswerRe: MSBuild unable to compile a project in a solution file, if project name contains dot "." Pin
Paul Conrad30-Jul-07 12:20
professionalPaul Conrad30-Jul-07 12:20 
GeneralRe: MSBuild unable to compile a project in a solution file, if project name contains dot "." Pin
Mushtaque Nizamani30-Jul-07 18:17
Mushtaque Nizamani30-Jul-07 18:17 
QuestionHow to use Microsoft Ajax with a textbox Pin
bucheron00730-Jul-07 5:04
bucheron00730-Jul-07 5:04 
AnswerRe: How to use Microsoft Ajax with a textbox Pin
codingrocks30-Jul-07 19:40
codingrocks30-Jul-07 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.