Did you install the Summer 2003 update or an older one? They all install a little differently.
For starters, the Microsoft.DirectX namespaces aren't available until the assembly that declares them is referenced. To reference these, first try installing the managed extensions (one one of the installations, these weren't installed while installing the SDK - don't remember which, though) from DXSDKDIR\Developer Runtime\Managed DirectX then from either the Debug or Retail directory. Start VS.NET and you should see the DirectX managed assemblies in the list now.
If you don't, find the location of the installed libraries (like %WINDIR%\Microsoft.NET\Managed DirectX\v9.00.1126) and add the path to the HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders registry key using regedit.exe.
I've installed three or four different versions / updates since the first managed assemblies were released over a short period of time to, unfortunately, I can't remember how they all behaved during installation. The directions above should do the trick, though.
i installed the summer 2003 update. i see the dlls in C:\WINNT\Microsoft.NET\Managed DirectX\v9.00.1126. i followed your directions, but i'm not sure if it worked. when i try and add a reference, i don't see any directx dll's on the .net tab. on the com tab, i see things like direct 1.0 type library, directx 8 for visual basic type library, among others. do i use one of these? i tried a few of them, but nothing seemed to work.
Did you start/restart VS.NET? Once you add that registry key like the others you should've seen in there, VS.NET won't pick them up again if you've already opened the Add Reference dialog once before. You have to restart for the change to take effect.
I wouldn't recommend using the COM interface. Developers were doing that before DirectX 9 introduced the managed assemblies and it was always a pain. There are several articles here on CP that dealt with those cases (or encapsulated the native functions).
If you're still having trouble after trying all this, go to http://msdn.microsoft.com/directx[^] and check out any support articles that seem relevant. This should all work, though. I had to do it once after installing one of the versions (DirectX 9.0, then a, then b, then Summer 2003 update) and everything has worked fine after that. Now if I could only find a good DirectX development book because I have a passive interest in games development (just curiousity, mostly).
.NET Game Programming with DirectX 9, Alexandre Lobao. APress.
Managed DirectX 9 Graphics and Game Programming, SAMS.
Lobao's book was "panned" by lots of reviewers, and i have to admit i didn't build the projects (actually i hardly parse vb) but to me it seems like a great overview of how stuff is actually written (there are lots of technical books on 3d, kinematics etc for further reading if you get interested).
In C#, how can I convert an object (class) to an array of bytes, send that to someone else (e.g., with sockets), and then recreate that object with that array of bytes. Is using BinaryFormatter on a MemoryStream what I need?
To further complicate things, what if I don't know the class type, but I KNOW that it is derived from a particular base class? E.g., I know it's a CAnimal, but I don't know if it is a CElephant or a CDog. How can I find out?
MyClass o = new MyClass();
publicvoid Bar(object data)
MyClass o = (MyClass)data;
In .NET, everything deriving from Object (except for ValueType and its derivatives like the intrinsics, enums, and structs) are reference types already (well, the instances of the classes deriving from Object) and everything derives from Object. So, for anything declared as a class, it's instance is a reference type.
As far as sending objects to another context, .NET Remoting is the de facto technology in .NET to do this. In the base class library, you can choose from the BinaryFormatter or the SoapFormatter (binary would obviously be faster but not easily interoperable with other technologies like J2EE). Serialization is required when crossing different contexts (even within the same AppDomain) and Remoting is recommend (required in some cases) when crossing AppDomains (even within the same process, which it's recommended you use a TcpChannel for communication). See Accessing Objects in Other Application Domains[^] on MSDN for more information.
As far as dealing with base classes, this is easily handled by an object-oriented framework like .NET and Java. For example, you could declare a parameter as even an Object, or the base class for your objects. The Common Type System (CTS) will ensure that when you're compiling any direct calls to that method use a parameter that is indeed a derivative class of the parameter Type. If you use abstract and virtual methods in your base class and override those in your derivative classes, those methods will be called instead of their base class's methods (you can use the base keyword to call the base class's methods inside the overridden methods). This is polymorphism. See the Common Type System[^] for some more information.
For example, the Object class has a virtual ToString method that, by default, returns the object's Type. If a class overrides this, it can return something else. An Enum returns the enum member name (or a comma-delimited list of names for enums that are attributed with the FlagsAttribute). Many other classes override this method as well.
Also, the Object.GetType method is not virtual and will return the actual Type of the object, regardless of whether the variable is declared as an object or another base class:
object o = new Button();
So, you can use the GetType to see if you're dealing with an Elephant or a Dog (BTW, the hungarian notation is not recommended for use in .NET languages - just thing of what the base class library uses for examples of how to name your classes, etc., or see the Naming Guidelines[^]).
The C# language makes this easier with several keywords you can use, such as is and as:
publicvoid Feed(Animal a)
if (a is Elephant) Buy(Food.Peanuts);
if (a is Dog) Buy(Food.Peanuts);
Of course, the above example is better suited for polymorphism by using the abstract keyword and overriding in the derivate classes to feed the animal what's necessary, but it's just an example.
Good! I hope I didn't offend you talking about polymorphism. I just usually make assumptions if nothing is indicated in a post to avoid constant reposting to provide more information. If nothing else, someone googling for answers may find our little thread useful (which is why I dislike forum members taking questions directly to me via email - it doesn't benefit the community).
for a testproject I have to load an assembly from a path different to the execution path of my application. the assembly I want to load references other assemblies, which are not system assemblies or assemblies referenced by my application.
the way I load this assembly is easy and works: Assembly MyAssembly=System.Reflection.Assembly.Load(AssemblyPathandName);
when I enumerate the members of a class of this assembly and the member (for example a method) has a returntype which is declared in a referenced (but not yet loaded) assembly, my application crashs.
now my question:
how can I load the referenced assemblies or how can I change the searchpath of my application, so that the referenced assemblies can be found and loaded automatic??????
There are a few ways that assemblies are found. First, the CLR will read from <runtime> section of the .config file and see if you've configured any paths for bound assemblies. The application will then use assemblies in the Global Assembly Cache (GAC), starting with native (pre-JIT'd) assemblies first, then the other assemblies (those not pre-JIT'd). Assemblies are then used out of the application directory (the directory where you .exe executable is located), followed by any additional subdirectories configured in the <probing> section of you .config file.
You can also handle the AppDomain.AssemblyResolve event and specify from where the assembly should be loaded (for example, from a different path, across the Internet/an intranet, or even from some Stream), but it's typically better and easier to maintain to work with the CLR and and let Fusion (the assembly binder) do its job.
We have an assembly that is in the GAC, but it’s a .NET component that is used inside visual studio itself. Ie it’s a .NET assembly control you drag onto a windows form application. I am trying to install the assembly on a remote machine (installshield devstuio 9) and get it to show up as a reference automatically in vstudio2003. How can I automatically add a reference to Visual studio in an installer / registry hack / command line that links to an assembly in the GAC? Without having to browse for it from the GAC.
For some weird reason, VS.NET doesn't see assemblies in the GAC. You have to add a registry key under HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders (see the existing ones for examples). Add the path to the assemblies outside the GAC, though it would be good to add the assemblies to the GAC, too, since it bolsters versioning and - if you ngen then (pre-JIT / generate native code for the target machine) - they'll be much faster to load.
So, the project that references those DLLs will link against the assemblies outside the GAC (the ones in the path that you added to the registry key above) but when you run the application, they'll use the assemblies out of the GAC.
First of all, Heath, I'd like to thank you so much for contributing so much to this community. Man, I've opened the C# page, and all the threads I saw were answered by you! Now I'm saying this regardless of whether you answer my question or not. Although I might become nasty if you don't!!! Just kidding
Say I have a number of InternetExplorer objects (say 3). Say I have all of them attached to one DownloadComplete event, which does the following:
// First, save the document's source to a string for processing.<br />// Second, actually process this string, and update a database.<br />
1- When I do InternetExplorer.Navigate2(...) any page, this does not stop the code execution, correct? In other words it sort of starts in a different thread?
2- Should I be taking any measures to prevent the DownloadComplete from being accessed while it's already executing? In other words: what happens if one InternetExplorer object finished downloading the document, started executing the code attached in the event handler, and while it's executing it, another InternetExplorer finishes and tries to execute it?
My God, I really sound dumb to myself, I'm sure some people look at this and sigh! Again, thank you for answering.
"A good friend, is like a good book: the inside is better than the cover..."
I think it is safer to start a new thread in that event and do lock and unluck for that string that you process it,cause even each handler run on seprate thread if you have some public variable that changed there it will cause problem or uncorrect data. I hope I was clear.
uhmm,let me explain . Imagine you have a public variable named a. You have two thread than wants to change this value, then what will happend? I'm not sure in the situation that you register one method as an event handler for two control this will happend too.It is called Thread Synchronization . You can see this article to understand more and search CP for other information about threading for more info and samples: