Archived

This forum has been archived. Please start a new discussion on GitHub.

C# exception help

I have a class Subscriber
class Subscriber : Ice.Application
{
...
}
in run method, I try to initial communicator and proxy, but the
communicator().createObjectAdapter("test.Subscriber"); failed.

The code looks like below
///////////////////////////////////////////////////
Subscriber sub = new Subscriber()
sub.main(args, "c:\\Config.sub");
...
//code initial m_communicator, (successl)
//code creates and objectProxy and TopicManagerProxy are success
...
//line causes exeption

m_ObjectAdapter = m_communicator.createObjectAdapter("test.Subscriber");

c:\config.sub file looks like below
TopicManager.Proxy=IceStorm/TopicManager:default -h 127.0.0.1 -p 10000
test.Subscriber.Endpoints=tcp:udp


debug message :

- e {"Exception of type 'Ice.InitializationException' was thrown."} Ice.Exception {Ice.InitializationException}
+ [Ice.InitializationException] {"Exception of type 'Ice.InitializationException' was thrown."} Ice.InitializationException
- base {"Exception of type 'Ice.InitializationException' was thrown."} System.Exception {Ice.InitializationException}
- Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
+ [System.Collections.ListDictionaryInternal] {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal
IsFixedSize false bool
IsReadOnly false bool
+ Keys {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
- Values {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
+ [System.Collections.ListDictionaryInternal.NodeKeyValueCollection] {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} System.Collections.ListDictionaryInternal.NodeKeyValueCollection
Count 0 int
IsSynchronized false bool
SyncRoot {object} object
HelpLink null string
- InnerException null System.Exception
- Static members
- Non-Public members
_COMPlusExceptionCode -532462766 int
Message "Exception of type 'Ice.InitializationException' was thrown." string
Source "Ice" string
StackTrace " at Ice.ObjectAdapterI..ctor(Instance instance, Communicator communicator, ObjectAdapterFactory objectAdapterFactory, String name, RouterPrx router, Boolean noConfig)\r\n at IceInternal.ObjectAdapterFactory.createObjectAdapter(String name, RouterPrx router)\r\n at Ice.CommunicatorI.createObjectAdapter(String name)\r\n at wpublisher.Subscriber.CreateAdpater(String[] args) in E:\\projects\\winformIceStorm\\publisher\\Form1.cs:line 927" string
- TargetSite {Void .ctor(IceInternal.Instance, Ice.Communicator, IceInternal.ObjectAdapterFactory, System.String, Ice.RouterPrx, Boolean)} System.Reflection.MethodBase {System.Reflection.RuntimeConstructorInfo}
+ [System.Reflection.RuntimeConstructorInfo] {Void .ctor(IceInternal.Instance, Ice.Communicator, IceInternal.ObjectAdapterFactory, System.String, Ice.RouterPrx, Boolean)} System.Reflection.RuntimeConstructorInfo
+ base {Void .ctor(IceInternal.Instance, Ice.Communicator, IceInternal.ObjectAdapterFactory, System.String, Ice.RouterPrx, Boolean)} System.Reflection.MemberInfo {System.Reflection.RuntimeConstructorInfo}
Attributes FamANDAssem | Family | HideBySig | SpecialName | RTSpecialName System.Reflection.MethodAttributes
CallingConvention Standard | HasThis System.Reflection.CallingConventions
ContainsGenericParameters false bool
IsAbstract false bool
IsAssembly false bool
IsConstructor true bool
IsFamily false bool
IsFamilyAndAssembly false bool
IsFamilyOrAssembly false bool
IsFinal false bool
IsGenericMethod false bool
IsGenericMethodDefinition false bool
IsHideBySig true bool
IsPrivate false bool
IsPublic true bool
IsSecurityCritical true bool
IsSecuritySafeCritical true bool
IsSecurityTransparent false bool
IsSpecialName true bool
IsStatic false bool
IsVirtual false bool
+ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle
+ Non-Public members
- Static members
- Non-Public members
_COMPlusExceptionCode -532462766 int
- Non-Public members
+ [Ice.InitializationException] {"Exception of type 'Ice.InitializationException' was thrown."} Ice.InitializationException
_className "Ice.InitializationException" string
+ _data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
_dynamicMethods null object
+ _exceptionMethod {Void .ctor(IceInternal.Instance, Ice.Communicator, IceInternal.ObjectAdapterFactory, System.String, Ice.RouterPrx, Boolean)} System.Reflection.MethodBase {System.Reflection.RuntimeConstructorInfo}
_exceptionMethodString null string
_helpURL null string
_HResult -2146233088 int
_innerException null System.Exception
_ipForWatsonBuckets 37546801 System.UIntPtr
_message null string
_remoteStackIndex 0 int
_remoteStackTraceString null string
- _safeSerializationManager {System.Runtime.Serialization.SafeSerializationManager} System.Runtime.Serialization.SafeSerializationManager
+ Static members
+ Non-Public members
_source "Ice" string
+ _stackTrace {sbyte[80]} object {sbyte[]}
_stackTraceString null string
_watsonBuckets null object
_xcode -532462766 int
_xptrs 0 System.IntPtr
HResult -2146233088 int
IsTransient false bool

Comments

  • benoit
    benoit Rennes, France
    Hi,

    The debug stack trace doesn't show the reason of the failure which is in theory embedded with the Ice.InitializationException. Do you have the PDB installed next to the Ice assemblies or registered with the GAC (see here for more information on using the .NET Ice assemblies)?

    The exception should contain the reason of the failure if you print it out:
    try
    {
        m_ObjectAdapter = m_communicator.createObjectAdapter("test.Subscriber"); 
    }
    catch(Ice.InitializationException ex)
    {
         System.Console.Out.WriteLine(ex);
    }
    

    Most likely, it's a configuration problem and the test.Subscriber.Endpoints property isn't being correctly read. I noticed an extra space in the name of the adapter passed to m_communicator.createObjectAdapter, is it a typo in your code or just a copy/paste problem?

    Cheers,
    Benoit.
  • The extra space is paste problem. Some how ZeroC forum alwasy insert a space into it.

    I will try you suggestion to figure it out.

    BTW, since Ice.Application is design for console. I can not use it for win form application, right? Because of the thread safe issue?


    benoit wrote: »
    Hi,

    The debug stack trace doesn't show the reason of the failure which is in theory embedded with the Ice.InitializationException. Do you have the PDB installed next to the Ice assemblies or registered with the GAC (see here for more information on using the .NET Ice assemblies)?

    The exception should contain the reason of the failure if you print it out:
    try
    {
        m_ObjectAdapter = m_communicator.createObjectAdapter("test.Subscriber"); 
    }
    catch(Ice.InitializationException ex)
    {
         System.Console.Out.WriteLine(ex);
    }
    

    Most likely, it's a configuration problem and the test.Subscriber.Endpoints property isn't being correctly read. I noticed an extra space in the name of the adapter passed to m_communicator.createObjectAdapter, is it a typo in your code or just a copy/paste problem?

    Cheers,
    Benoit.
  • C# Adpator Exception

    Hi

    The problem is in code below

    m_SubscriberObjPrx = m_ObjectAdapter.add( new TestReaderI (), new Ice.Identity());

    -

    ex {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} Ice.Exception {Ice.ObjectAdapterDeactivatedException}
    - [Ice.ObjectAdapterDeactivatedException] {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} Ice.ObjectAdapterDeactivatedException
    - base {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} Ice.LocalException {Ice.ObjectAdapterDeactivatedException}
    - base {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} Ice.Exception {Ice.ObjectAdapterDeactivatedException}
    - base {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} System.Exception {Ice.ObjectAdapterDeactivatedException}
    + Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
    HelpLink null string
    HResult -2146233088 int
    + InnerException null System.Exception
    Message "Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown." string
    Source "Ice" string
    StackTrace " at Ice.ObjectAdapterI.checkForDeactivation() in c:\\IceBuilds\\VC9\\Release\\cs\\src\\Ice\\ObjectAdapterI.cs:line 1317\r\n at Ice.ObjectAdapterI.addFacet(Object obj, Identity ident, String facet) in c:\\IceBuilds\\VC9\\Release\\cs\\src\\Ice\\ObjectAdapterI.cs:line 460\r\n at Ice.ObjectAdapterI.add(Object obj, Identity ident) in c:\\IceBuilds\\VC9\\Release\\cs\\src\\Ice\\ObjectAdapterI.cs:line 452\r\n at wpublisher.Subscriber.SetAdapterAndRun(String option) in E:\\projects\\winformIceStorm\\publisher\\Form1.cs:line 979" string
    + TargetSite {Void checkForDeactivation()} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
    + Static members
    + Non-Public members
    name "Test.Subscriber" string
    + base {"Exception of type 'Ice.ObjectAdapterDeactivatedException' was thrown."} System.Exception {Ice.ObjectAdapterDeactivatedException}

    m_ObjectAdapter look like this:

    m_ObjectAdapter {Ice.ObjectAdapterI} Ice.ObjectAdapter {Ice.ObjectAdapterI}
    - [Ice.ObjectAdapterI] {Ice.ObjectAdapterI} Ice.ObjectAdapterI
    _acmTimeout 0 int
    _activateOneOffDone false bool
    + _communicator {Ice.CommunicatorI} Ice.Communicator {Ice.CommunicatorI}
    _deactivated true bool
    _destroyed true bool
    _destroying false bool
    _directCount 0 int
    _hasAcmTimeout false bool
    _id "" string
    + _incomingConnectionFactories Count = 0 System.Collections.Generic.List<IceInternal.IncomingConnectionFactory>
    _locatorInfo null IceInternal.LocatorInfo
    _m {IceUtilInternal.Monitor} IceUtilInternal.Monitor
    _name "Test.Subscriber" string
    _noConfig false bool
    _objectAdapterFactory null IceInternal.ObjectAdapterFactory
    _processId null Ice.Identity
    + _publishedEndpoints null System.Collections.Generic.List<IceInternal.EndpointI>
    + _reference null IceInternal.Reference
    _replicaGroupId "" string
    + _routerEndpoints null System.Collections.Generic.List<IceInternal.EndpointI>
    _routerInfo null IceInternal.RouterInfo
    + _servantManager {IceInternal.ServantManager} IceInternal.ServantManager
    _threadPool null IceInternal.ThreadPool
    _waitForActivate false bool
    _waitForHold 0 int
    _waitForHoldRetry false bool
    + instance_ null IceInternal.Instance
    + Static members
  • bernard
    bernard Jupiter, FL
    Hi Chang,

    In your first post, createObjectAdapter was raising an exception (Ice.InitializationException). In your second post, your program is apparently going further and raising Ice.ObjectAdapterDeactivatedException when you call add on your object adapter.

    ObjectAdapterDeactivationException is raised, as its name indicates, when the object adapter is deactivated; you would typically deactivate your object adapter by shutting down its communicator.

    Best regards,
    Bernard