C# version of the Archival Callback Handler

Problems with Archival Server

C# version of the Archival Callback Handler

Postby owen » Wed Nov 19, 2014 10:16 am

The Unreal SDK 10.0 provides a sample C++ Visual Studio project for Archival Callback Handling (ArchEvtComsumer) and a C# Visual Studio project for Archival Control (UArchCtrlSample). I am trying to make a C# version of ArchEvtConsumer.

I managed to convert .tlb file provided in the ArchEvtComsumer sample to get a c# Interop dll like the one provided in the UArchCtrlSample version using the following command:
tlbimp UArchivalCallbacks.tlb /out:Interop.UArchicalCallbacks.dll /namespace:UArchivalCallbacks

I then (attempted) to write a ComVisible C# DLL that inherits from the UArchivalCallbacks interfaces which I was able to register on my target machine with the following command:
regasm ArchEvtConsumer.dll /codebase /tlb

Unfortunately the Archival tool refuses to accept the ProgId as valid. However, I believe that I am very close to getting the interface correct, as I have had it working briefly when I managed to force the Archival tool to accept the ProgID without properly checking it via accidentally exploiting bug in the archival tool GUI (see explaination below). However, I can't reliably reproduce this and it is obviously not a proper solution. Does anyone know what I am doing wrong? I would be very interested to see a working sample if Unreal would be interested to add one to the SDK.

Sample code:

--------------------------------------------------------------------

using System;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace ArchEvtConsumer
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(UArchivalCallbacks.IUArchivalRecordNotifier))]
[ProgId("ArchEvtConsumer.ArchEvtConsumer")]
[Guid("399f5101-6e20-4843-81ac-01cf39d1e86d")]
[Description("ArchEvtConsumer Class")]
public class ArchEvtConsumer : UArchivalCallbacks.IUArchivalRecordNotifier, UArchivalCallbacks.IUCallbackComponentSettings
{
#region Constructor & Destructor

public ArchEvtConsumer()
{
;
}

~ArchEvtConsumer()
{
;
}

#endregion

#region COM Interface IUCallbackComponentSettings

public void SetParameters(string bstrParameters)
{
;
}

#endregion

#region COM Interface IUArchivalRecordNotifier

[Description("method Init")]
public void Init(string bstrServerAddress, string bstrSourceName)
{
;
}

[Description("method RecordingStarted")]
public void RecordingStarted(string bstrClipFilePath, ref Guid pRecordID)
{
;
}

[Description("method RecordingFinished")]
public void RecordingFinished(ref Guid pRecordID)
{
;
}

[Description("method Uninit")]
public void Uninit()
{
;
}

#endregion
}
}

--------------------------------------------------------------------

The GUI bug: When you configure a consumer via the Archival Control GUI I think you are supposed to click the "Configure Consumer" button that opens a window where you enter the "ProgId" and "Init String" for your consumer. You then click "OK" to close the window, and "Update" to save the settings. If you Enter a "ProgId" that the application does not like and then click "OK" it will open an error dialog, but it does not stop you from closing the window by pressing the "X", but you are unable to click the "Update" button because it has been disabled. If you then reopen the window by pressing "Configure Consumer" again your bad "ProgId" is still displayed in the box, if you do not change it, but instead change the "Init String" then click the "OK" you will not get an error message and the "Update" button will be enabled because the GUI has detected that the properties have been modified. Once you click update, I think the application has now accepted the "ProgId" without proper validation.
owen
 
Posts: 0
Joined: Wed Nov 19, 2014 9:13 am

Re: C# version of the Archival Callback Handler

Postby admin » Wed Nov 19, 2014 7:26 pm

Hi,
is your version of C# ArchEvtConsume 32 or 64 bit? It must be 32-bit.
admin
Site Admin
 
Posts: 1030
Joined: Fri Aug 21, 2009 10:13 am

Re: C# version of the Archival Callback Handler

Postby owen » Thu Nov 20, 2014 3:06 am

Hi,
I believe it is 32bit. It is part of a Visual Studio configuration of "Any CPU", but the displayed "Platform Target" in the Build tab is "x86".
owen
 
Posts: 0
Joined: Wed Nov 19, 2014 9:13 am

Re: C# version of the Archival Callback Handler

Postby admin » Tue Nov 25, 2014 3:12 pm

It must be a 32-bit assembly, not Any-CPU.
You should be able to consume your COM-visible c# assembly from another c# App - does it work?
admin
Site Admin
 
Posts: 1030
Joined: Fri Aug 21, 2009 10:13 am

Re: C# version of the Archival Callback Handler

Postby frankchen » Thu Dec 04, 2014 10:39 pm

I'm in the process of trying to make a C# version of ArchEvtConsumer, too.
First I convert Unreal ArchEvtConsumer sample soulition to Visual Studio 2012, then just build it and successful done this.
Second, I register that ArchEvtConsumer.dll file and got a successful report.

After that,I creat a new project as my C# version of ArchEvtConsumer, then add the ArchEvtConsumer.dll that I've registered as a reference.
At this moment, I see a yellow mark on the referenced component. Despite that, I try to build the solution, and get an error message shown as following:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(2015,5): error MSB3304: Could not determine the dependencies of the COM reference "ArchEvtConsumerLib". Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))

BTW, I've definitely understood what you've said on this post, and set the "Platform Target" in the Build tab of Visual Studio configuration to "x86".

Does Admin have any idea?
frankchen
 
Posts: 0
Joined: Fri Oct 03, 2014 1:31 am

Re: C# version of the Archival Callback Handler

Postby frankchen » Mon Dec 08, 2014 8:16 pm

Hi Admin,
DO you have any explanation for me on my post? Actually, I also wote an email last week shown as following. It's the same problem, even we try to take another plan to reach the same goal. But still failed to do that.

The mail which I wrote
=======================================================================================
Hi,
My team is hard trying to create a project by using Unreal ArchEvtConsumber.dll for collecting events issued from your archive server.

First we tried to use ArchEvnConsumer sample project which is included in Unreal SDK, but we faced some problem and failed to do that. I have post that problem on forum today.

Now we change our plan, and try to open another C# project, then add UArchCallbackPS.dll into it as a reference component. Untill now, everything is fine. We successfully build this project and run it without error happened.

After that, we try to make some abnormal things happened and hope to trigger an callback function. We plug out the ethernet cable which is attached with an IPCAM, that is connected into Unreal Media server and continuing recording through Archive Server. But nothing happened, callback function is not triggered.

In the meantime, the red triangular mark on Archive server, which is indicated that IPCAM is recording now, is still lighting. Normally it should be shown a cross mark and represents that recording failed, right?

We've stucked with this for a few days. Could you give us help? Any clues will be appreciated.
======================================================================================
frankchen
 
Posts: 0
Joined: Fri Oct 03, 2014 1:31 am

Re: C# version of the Archival Callback Handler

Postby admin » Mon Dec 08, 2014 8:57 pm

Please give us some time to investigate the issue and write a c# consumer ourselves.
Of course it's doable since you have a type library and can implement an interface in a COM-visible assembly.
admin
Site Admin
 
Posts: 1030
Joined: Fri Aug 21, 2009 10:13 am

Re: C# version of the Archival Callback Handler

Postby admin » Tue Dec 09, 2014 5:29 pm

Hi,
we've just created working C# callback COM object.
1. Make sure you use strong-named assembly. For this create a key pair that will be used to sign the .NET assembly with a strong name. ["sn -k key.snk" at the command prompt]. Add an assembly attribute to your object cs file. “[assembly:System.Reflection.AssemblyKeyFileAttribute(@"..\..\key.snk")]“
2. Generate a globally unique identifier for use with your callback COM object.
3. Use System.Runtime.InteropServices.GuidAttribute to generate an attribute for class COMObject, like this:
[GuidAttribute("165371DA-6089-4D61-89A2-D96A4CDB18AE")]
public class NetConsumer : UArchivalCallbacksLib.IUArchivalNetworkNotifier
4. Register the Assembly. ["regasm CSharpCOM.dll /tlb:CSharpCOM.tlb /codebase NetConsumer" at the command prompt, while in the directory that contains CSharpCOM.dll]. don't forget to use stong-name after /codebase.

In the example above COM object ProgID will be CSharpCOM.NetConsumer .

For those who are not able to add UArchivalCallbacks type library reference to your C# project make sure to first register UArchivalCallbacks.tlb file. We have utility for that if you need.
admin
Site Admin
 
Posts: 1030
Joined: Fri Aug 21, 2009 10:13 am

Re: C# version of the Archival Callback Handler

Postby admin » Tue Dec 09, 2014 5:37 pm

You may download sample C# projects from: http://www.umediaserver.net/exchange/UA ... nsumer.zip
admin
Site Admin
 
Posts: 1030
Joined: Fri Aug 21, 2009 10:13 am

Re: C# version of the Archival Callback Handler

Postby frankchen » Wed Dec 10, 2014 8:09 pm

Hi Admin,
Thanks for your help. Got your sample project and try it under way. Until now, the result is the same.
Now we have something confused, and I need some explanation.
1. In order to validate our code is functionally correct, we have to make an event happened which could trigger a callback function. But, how to do that?
Exactly to say that, could you tell me how to make the IUArchivalNetworkNotifier:OnConnect and IUArchivalNetworkNotifier:OnDisConnect methods occurred?
As what I said on this forum, even I plug out the ethernet cable of IPCAM, or manually start/stop recording via the config window of archive server. Just nothing happened,
no event be triggered. Why?
2. So, I would like to know What the rule is about Unreal's Notifier callback mechanism.

Thanks for your kindly help again.
frankchen
 
Posts: 0
Joined: Fri Oct 03, 2014 1:31 am

Next

Return to Archival Server

Who is online

Users browsing this forum: No registered users and 0 guests

cron