|
Ah ok...
We can't send a complete class, but we can send simply a structure derived from ValueType...
in a class that handle DirectPlay, is it necessary to use trnasactions with
[Transaction(TransactionOption.Required)] ?
Or the flag SendFlags.Guaranteed is enough?
NB: thanks for the link, but the MSDN is largely enough. I just messed up with the parameters... they need to be a structure, not a class :P
There is no spoon.
|
|
|
|
|
The TransactionAttribute is for service components (i.e., COM+ services), not DirectPlay (or any DirectX). They have nothing to do with each other. You can't just mix and match APIs.
If you want to send a class, use the Client.Send overload that requires a GCHandle , as I mentioned before. Most importantly, read the docs. I know the DirectX SDK documentation sucks (NDoc[^] is free and does a better job), but at least you can see what classes and members are available; that's all I did to answer your question (since I knew the basics already).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have created a structure with basic data (bool & int) and the structure is not sent. there is an exception that tells "An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Object contains non-primitive or non-blittable data."
while the strcuture looks like this:
public struct TetrionParams
{
#region Fields
public bool DrawGrid;
public bool Draw3D;
public bool ShowGhostPolymino;
public bool ShowNextPolymino;
public int Width, Height;
#endregion
}
There is no spoon.
|
|
|
|
|
How are you calling Client.Send with this struct? More information is required to help you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
that's okay, I've found a sample in the tutorials of DirectX that shows how to send binary data.
the data need to be transfered byte by byte in the NetworkPacket. the Tut10_ThreadPool tutorial in the ThreadPool.SendData() method.
There is no spoon.
|
|
|
|
|
Hi ..
I'm writting a video player in C# using DirectShow ..
I would like to play Quicktime movies and VR too .. i found the Interop.QTActiveXPlugin.dll .. but i have not been able to play a single movie ..
I hope some one can help me get a Quicktime movie to play in C# without using an embeded HTML page containing a Quicktime <object> ..
Thanx ..
|
|
|
|
|
buffer_k.st wrote:
i found the Interop.QTActiveXPlugin.dll .. but i have not been able to play a single movie ..
For one, you must have QuickTime installed on your machine. An interop assembly is an RCW (Runtime Callable Wrapper) that exposes an existing COM server to .NET. The QuickTime ActiveX control is installed on Windows when you install QuickTime. Second, you can make your own. By saying you "found" the interop assembly - do you trust the source? All you have to do to make one is, in VS.NET, right-click on your project, select Add Reference, click on the COM tab, and find the QuickTime library. Double-click to add it. This create an interop assembly.
However, you must also create an ActiveX wrapper. Do this by right-clicking on your toolbox and selecting "Customize" (it's a little different for different versions of VS.NET, but common sense should tell you want to click). Find the ActiveX control for QuickTime and double-click to add it. When you drag this to your form or user control, both the ActiveX interop assembly and the interop assembly you created above (if you haven't yet) are created automatically for you. It's this ActiveX control (AxHost derivative) that you use to display videos.
You cannot use DirectShow to play newer (like, within the last few years) QT files because they do not use a compatible codec (on purpose), just as RealNetworks doesn't.
Finally, if you're having a problem, please be specific. Saying something like "but i have not been able to play a single movie .." doesn't help. Are you getting any exceptions? Do you just not know what to do?
The last question shouldn't be a problem, though. Follow the instructions above, or search for existing articles. It's really quite easy.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok to be more specific ..
Quicktime was already installed .. i found the quicktime COM "QTPlugin.ocx" wich contain Interop.QTPlugin.dll .. but i can't find the axInterop (ActiveX) dll file ..
I downloaded the Quicktime 6 SDK but it is for JAVA and C++ .. I've been searching all over to find the quicktime ActiveX .. but can't find it .. please help ..
|
|
|
|
|
As I mentioned previously, you must customize your toolbox (where all the controls are) and add the QuickTime ActiveX control in there. In fact, forget the step of creating an interop assembly manually - that only defines the types exported from a COM typelib.
When you drag that QuickTime ActiveX control from the toolbox to your form, VS.NET automatically creates the "AxInterop" and "Interop" assemblies. Before doing this, however - if you plan on deploying your application outside of your control, right-click on your project in VS.NET and find the AssemblyKeyFile and AssemblyKeyName properties (something like that). If you want to generate a strong name assembly - even for the interop assemblies (in order to install into the GAC or for purposes of assembly binding redirection) - type the project-relative or absolute path to your key pair file, or type the name of the key container that contains your key pair.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I did what u said .. and it works perfectly ..
Thank you very much for helping me out .. I didn't realize it was that simple and that powerful ..
|
|
|
|
|
Hi Everybody!
I have a question concerning outlook add-ins written in c#. I'd like to write such an add-in but just can't get this thing to work. The main problem is that I don't own a vs.net license, but use SharpDevelop. I used VS.net's wizard at university to create a short plugin template and filled it with some code I found in an MSDN blog article (http://blogs.msdn.com/dancre/archive/2004/03/21/93712.aspx).
But whatever I am trying, I just can't get this thing to work. At home I installed the office XP PIAs and referenced them from the project. I had a look at the installation project from the VS.net solution and added the same registry keys:
<br />
Windows Registry Editor Version 5.00<br />
<br />
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlook\Addins\SharpPrivacyOutlook.Connect]<br />
"LoadBehavior"=dword:00000003<br />
"Description"="Outlook Add-in for OpenPGP Encryption"<br />
"FriendlyName"="SharpPrivacy Outlook"<br />
However even though the project compiles all right in sharpdevelop, it doesn't get loaded by outlook. If i try to install it manually (in Outlook - Extras - Options - Extended Options - COM Add-Ins [roughly translated from the German Outlook version]), I get the error message: "SharpPrivacyOutlook.dll is not a valid office add-in".
Is there anything else I need to do to install the add-in? Just in case someone wants to have a look at the code or the dll, I put a copy on the project webserver.
I'm glad for any kind of help!
Thanks in advance,
Daniel
---
SharpPrivacy - A free OpenPGP Implementation in c#
http://sharpprivacy.sf.net
|
|
|
|
|
It's not a valid COM add-in, and whether you use SharpDevelop, VS.NET, or command-line tools it doesn't matter.
A .NET assembly only has the same extensions as native executables, and resembles a PE/COFF executable up until the load address and data segments. It's actually more akin to a VB6 DLL. It doesn't contain the same entry points as a native COM DLL, so a shim is required.
You must actually register your .NET DLL using regasm.exe, after installing it into the Global Assembly Cache (GAC) using gacutil.exe; otherwise, specify regasm.exe /codebase when installing to register the path to the assembly.
This registers your .NET assembly as a COM DLL, but the actual InprocServer is mscoree.dll, the managed executable loader. It is the GUID under which your .NET assembly is registers that you should store in the Outlook options registry key. It will actually load mscoree.dll, which will marshal calls to and from your .NET assembly to Outlook.
There are articles about this on MSDN as well, though they talk about creating your own shim (which is stupid, since mscoree.dll that ships with the .NET Framework must exist and is already a shim!).
To make your .NET assembly a decent COM-visible assembly, you should follow several guidelines (like all COM should):- Attribute your assembly with a
GuidAttribute (like [assembly: Guid("01234567-0123-0123-0123-012345678901")]</coode>)<li>Attribute all classes and interfaces with unique <code>GuidAttribute s as well - Never use auto-generated class interfaces; always specify
ClassInterfaceType.None and explicitly define your interfaces and implement the class interface as the first interface - Never change your release interface declarations; always create new interfaces that inherit from them and implement those as the new class interfaces. Use a new
GuidAttribute as well, but don't remove the previous interface and make sure it's still implemented properly
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a lot Heath!!! That did it!
Do you by chance know a webpage where the COM guidlines are further detailed?
Thanks again,
Daniel
---
SharpPrivacy - A free OpenPGP Implementation in c#
http://sharpprivacy.sf.net
|
|
|
|
|
Look on MSDN[^], as with all things related to Microsoft development.
I honestly don't know of a specific page; I just know this from lots of experience with COM (~10 years) and .NET (since its initial beta). If you don't follow COM guidelines when creating CCWs (COM-Callable Wrappers), differents GUIDs (CLSIDs, TYPELIB IDs, and IIDs) may be re-generated with different numbers each time, auto-generated class interfaces can break existing code (when using IUnknown inheritance, or with IDispatch interfaces witout the DispIdAttribute , changing the order of methods will break COM clients), etc.
Study COM and apply those practices in .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have made a 32x32 cursor that uses a 16-colours palette. When the cursor is displayed at runtime, however, it appears on screen as a monochrome (black and white) image. Does anyone know why this occurs?
|
|
|
|
|
You might want to give specifics on how you're storing it (separate file, embedded resource in an assembly, etc.) and how you're loading it. It's kind of hard to diagnose a problem with specifics (it's like telling a doctor you have a pain without saying anything else).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
leppie wrote:
As I read today, the Cursor class only supports black and white cursors.
If it is the case that the Cursor class only supports black and white cursors, it changes the nature of my question from 'what am I doing wrong' to 'how can I display coloured cursors'. As Heath Stewart quite justly comments, let me show me what I've done sofar to create, load and display my cursor.
I created the cursor with Visual Studio 6.0. (By the way, earlier I created one by selecting "Cursor file" from the "Add New Item" dialog in Visual Studio .Net 2003 but that file appears to be an icon instead of a cursor. In the Properties Window it says "Icon Editor" and the hotspot tool is disabled. My old Visual Studio 6.0 recognised the file as an icon, too. I guess this may be a bug in Visual Studio .Net 2003 and I probably need an update for it. This is a different matter, however.) Anyway, this 16-coloured cursor works fine in a C++ 6.0 project. I also tested one of the coloured cursors that comes with WindowsXP; it also is displayed in monochrome, so I think we can discard the cursor file itself as the problem.
I embedded the cursor by setting the Build Action to Embedded Resource. I declare the cursor:
private Cursor MyCursor;
and in the constructor of my user control I load it:
System.Reflection.Assembly ThisDll = System.Reflection.Assembly.GetExecutingAssembly();<br />
System.IO.Stream TheRes;<br />
TheRes = ThisDll.GetManifestResourceStream("MyNamespace.MyCursor.cur");<br />
MyCursor = new Cursor(TheRes);
(I tried using simply
MyCursor = new Cursor(this.GetType(), "MyCursor.cur"); or
MyCursor = new Cursor(this.GetType(), "MyNamespace.MyCursor.cur");
but that didn't work: the dataStream remains empty, apparently.)
I asign the cursor (in special cases) to the user control by:
this.Cursor = MyCursor;
All in all, I'm doing nothing odd, I would say. So where have my wonderful colours gone?
I would appreciate anyone's help on this. I cannot believe C# only allows monochrome cursors.
Thanks.
|
|
|
|
|
i want use from Axmediaplayer and i want doubleclick on it and then open another form .
i want serialize and deserialize AxmediaPlayer .
please help me
thanks.
|
|
|
|
|
You can serialize its properties, but not the whole player. Instead of serializing it to pass it to another form, just add it to the other Form 's Controls collection. So long as the forms are on the same thread, the AxMediaPlayer control will remove itself from it's current Parent 's Controls collection. This also re-creates the handle, though, which also makes the video stop.
If you're trying to implement a small <-> large switching, the media player itself already supports this. Download and install the Windows Media SDK (very small) from MSDN[^]. Then take a look at the scripting object model in the HTML Help file, specifically the PlayerApplication.switchToControl and PlayerApplication.switchToPlayerApplication methods. The scripting (i.e., automation) object model is the same as what is created for the interop assembly you're using.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
HI,
In my system, MyNetworkPlaces-> I have few network folders .
when I click those to view, it prompts the dialogbox to connect to that folder. If I give username and passwork it connects.
so now in my C# application, I am asking user to select a folder, by showing Browse for folder dialog box with server machine shared folder as default folder. The thing is before showing the file dialog box, I want to know whether it is connected to the server or not, if not I need to prompt the dialogbox with username and password fileds for connecting to it. so How can I achieve this using C#? and what class I need to use for connecting to network folder? I am really struggling for this. Please help me as soon as possible.
For ex:
I want to connect to \\machine1\somefolder
or \\machine2\somefolder, I need to know whether is it accessinble for user machine, if no i need to prompt the dialog box to connect with username and password as windows shows.
Thanking you
Regards
Subin
|
|
|
|
|
As has been covered in this forum several time before, this is a feature of Windows, not of networking itself (which expects a connection with the appropriate credentials). If the user can't access the folder, you should get a SecurityException . In such an event, you simply open a dialog (which you must create) to prompt for a username and password. You use that information - and do not store it - to impersonate the user using WindowsIdentity.Impersonate (for which the documentation contains an example of how to use it). Create a WindowsPrincipal using that identity, set that as the thread princial (assign it to the Thread.CurrentPrincipal property) and re-attempt the connection.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Good day,
I have a dll that disables/enables the keyboard using the SetWindowsHookEx, CallNextHookEx and UnhookWindowsHookEx api's. Now when i run my application, at first it does its job, but after awhile it generates this error:
/*
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an object.
*/
The error points to this part of my code:
static void Main()
{
try
{
Application.Run(new Form1());
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message); <----- error
}
}
Does this have to do with garbage collection?
Thanks Arthur
|
|
|
|
|
That doesn't tell us much. All it says is that somewhere in the Application.Run() method a NullReferenceException occurs.
You will need to find out where the exception was thrown from. For debugging purposes temporarily remove the try/catch statments so that the exception gets thrown out and allow the debugger to handle it. From there you should see lots of other useful information - The debugger will jump the source to the relevant line (or sometimes the line after), if it happened inside some system code you don't have access to the call stack will show you where that is.
If this information is not enough to work out the problem, please, at least post the call stack.
Arthur01291981 wrote:
Does this have to do with garbage collection?
What makes you think that? You know more about your application than we do. Is their something you've not told us that you think might be relevant.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
To add to what Colin said (since a NullReferenceException is the most common exception - and the easiest to prevent!), putting a try-catch around Application.Run doesn't help unless an exception causes the main UI thread to abort, and most won't; it is in your case, which means it's occuring in the message pump, or application thread queue.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|