Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

205 Neutral

About BTownTKD

  • Rank
  1. Sure, that's currently my approach; just keep using what works, and wrap it in a more logically-declared method, which handles all the copying/allocating/deallocating to IntPtrs. That said, I would still very-much like to know what exactly is wrong with my "proposed" DllImport declaration, that causes such grave marshaling errors. We have quite a few projects which rely on importing some legacy DLLs, and this knowledge could save us grief in the future, as well. My (somewhat) educated guess is that my arrays aren't being marshaled correctly (as you said), and I need to annotate them with something along the lines of [MarshalAs(UnmanagedType.LPArray)], or something. However, my hope was that someone would just be able to look at both the C function and my DllImport statement, and immediately offer up a "Well, thar's yer problem, right thar!"
  2. Hi guys; I'm porting an old VB.NET app to C#/WPF. The VB.NET app uses a communications library DLL written in C, through the use of DLLImport, and I can't seem to get the correct type marshaling to work in the rewritten C# app. Here's the original DLL method signature, as per a header file included in the SDK (please forgive the lack of variable names - it came that way.) I added the in/out comments myself, to reflect how each variable is used: [source lang="c"] int SendMessage( CUSTOM_STRUCT *, //in int, //in unsigned char *, //in unsigned char *, //in unsigned long, //in unsigned char *, //out unsigned long *, //out unsigned char *, //out unsigned long *, //out unsigned long *, //out unsigned long ); //in [/source] The unsigned char * are all byte arrays for sending data and receiving responses. The unsigned long * are typically for returning how long the previous unsigned char* should be, after recieving a response. I'm not sure any of that matters, however - I think the types are sufficient enough to derive an answer. Here is how the method was declared in the original VB.NET application: it works, but I don't like it because it's not "correct." For instance, all the byte arrays are declared to be a single ByRef Byte, but it is supposed to represent an array of bytes, and I feel that should be reflected in the method signature. [source lang="vbnet"] <DllImport("MyLibrary.dll")> _ Private Function SendMessage( ByRef myStruct As CUSTOM_STRUCT, _ ByVal requestType As Short, _ ByRef messagePath As Byte, _ ByRef request As Byte, _ ByVal request_size As Integer, _ ByRef response As Byte, _ ByRef response_size As Integer, _ ByRef extended_response As Byte, _ ByRef extended_response_size As Integer, _ ByRef resultCode As Integer, _ ByVal timeout As Integer) As Integer [/source] Here is how I tried to declare the DllImport in the C# re-write: [source lang="csharp"] [DllImport("MyLibrary.dll")] private extern static Int32 SendMessage( ref CUSTOM_STRUCT myStruct, //in Int32 requestType, //in ref byte[] messagePath, //in ref byte[] request, //in UInt32 request_size, //in ref byte[] response, //out ref UInt32 response_size, //out ref byte[] extended_response, //out ref UInt32 extended_response_size, //out ref Int32 resultCode, //out UInt32 timeout); //in [/source] But that doesn't appear to be working. I get all sorts of unexpected behavior; the sent messages are garbage, and I occasionally get protected memory errors. Obviously I'm not marshalling these types correctly. So I "cheated" - I modified the declaration to use IntPtr for all the reference variables, then whenever I use it I manually marshal everything to a bunch of temp IntPtrs. This appears to work, but I don't like it because it does not accurately represent the types going in and out. Not to mention the pain in the ass of manually marshaling IntPtrs and then cleaning up afterwards. [source lang="csharp"] [DllImport("MyLibrary.dll")] private extern static Int32 SendMessage( IntPtr myStruct, //in Int32 requestType, //in IntPtr messagePath, //in IntPtr request, //in UInt32 request_size, //in IntPtr response, //out ref UInt32 response_size, //out IntPtr extended_response, //out ref UInt32 extended_response_size, //out IntPtr resultCode, //out UInt32 timeout); //in [/source]
  3. Hi all; I'm looking for some kind of software delivery system for customers. Basically, we want to set up a way for my company to keep track of customers' software purchases, and allow them to download copies from our website. We'd want to allow users to see a complete list of all their purchased software, and provide temporary download links for each one. If they've purchased "update" subscriptions, then the they would also have access to newer versions of the software; if not, then they can only download the "older" versions. This is not necessarily for game software; we have some enterprise applications that we offer. I figure this has to be built into some of the open-source eCommerce packages out there, but I can't seem to find the right combination of Google keywords to use, to find the features I'm looking for. Does anyone know of software that can do this? Paid or open-source; it doesn't matter. [Edit: if this would be better suited for "Web Development", then please accept my apologies, and relocate this thread]
  4. I have a WPF application which I've structured using the MVVM design pattern. I would eventually like to extend the application in such a way that it will listen on an HTTP port, and allow remote users to make modifications via a Silverlight client. In order to accomplish this, I have a number of unknowns: 1) Are there any built-in .NET classes which I can use to easily instantiate a "server" object in the WPF application, in order to listen for HTTP requests? 2) Would there be any special steps required, to host a silverlight application from inside my WPF executable? 3) The end goal would be to have any changes made in the Silverlight interface automatically appear in the WPF user interface - I would ideally like to accomplish this by sharing the ViewModel objects between both the Silverlight and WPF Views, but I'm not sure if that is possible (would there be binary compatibility issues?). Thanks in advance for your thoughts, -Brian
  5. You'll want to familiarize yourself with the Microsoft Documentation. It's fairly helpful for simple tasks like this. http://msdn.microsof...v=vs.95%29.aspx In this case, you'lre probably looking for ListBox.Items, and ListBox.SelectedItem (or ListBox.SelectedItems for multi-selection). And maybe the ListBox.SelectionChanged event.
  6. I don't think you can delete the entire installation directory as part of your custom action. The uninstaller will do that automatically if the directory is empty, after the uninstall has completed. You'll probably need to limit the action, so it only deletes files and subdirectories which are not covered by the "standard" uninstall process (i.e. just the stuff you downloaded from within the app). Once those files and folders are gone, there should be nothing keeping the Uninstaller from deleting the Target Directory when it's done.
  7. BTownTKD

    [.net] Get an object by name

    PropertyInfo.SetValue() will do just that. You need to have a reference to the target object, whose Property you wish to change.
  8. Topic says it all. I'd like to do some stuff with Methods in .NET, but I also require that any method tagged with my custom Attribute also have a specific signature (for instance null MyMethod() - no parameters, no return type.) I can do this by throwing an exception at runtime, but it would be so much nicer to throw a compile-time error. Is there a way to enforce this at compile-time?
  9. Thanks for all the replies so far! Quote:Original post by Zipster A friend recommended "Y: The Last Man", and let me tell you it didn't disappoint. So if that's one of the ones you haven't read yet, get right on it! The subtle Shakespeare references were pretty neat too. "Watchmen" was alright, but it dragged on in a few places and I wasn't as impressed as everyone else seemed to be (read it before seeing the movie). Y: The Last Man was the only one on that list that I have not yet read. I'll get right on it. It seems like overall, the responses I'm getting from people (both on and off the Gamedev forum) is that - if you want a good comic series with an actual conclusion, read comics published by Vertigo.
  10. Hey guys - I'm looking for some comic series and graphic novels to read over break, and I was hoping to solicit some suggestions. I'm looking for COMPLETED series only; I just got caught up on "The Walking Dead," and nothing stings worse than knowing you have to wait a month between every tiny nibble, with no end in sight. They don't have to specifically be a lengthy series or a graphic novel; it just has to have a beginning, middle and (most importantly) an END. Examples of works I've recently read (or plan to read very soon): Sandman (Niel Gaiman) Y: The Last Man (Brian Vaughan, Pia Guerra) Arkham Asylum: Serious House on Serious Earth (Grant Morrison) The Dark Night Returns (Frank Miller) Watchmen (Alan Moore) I fancy fantasy, sci-fi, and dark themes, as you might be able to tell from the preceding list.
  11. Why not come up with a "weight" system, instead of relying solely on "player rating." For any given player looking for a match, every other potential player would have a "weight," determining the likelyhood of the 2 players being paired up. "Player ratings" would effect the weight the most, so players with a large rating difference will have (virtually) no chance of playing each other, and the likelihood increasing as player skill-levels become closer. However, other things will effect the weight to a lesser degree; "wait time" - how long a player has been waiting for a match. "recent-ness" of a partner-pairing - How recently have these 2 players been paired together? This effect will slowly dissipate after a few matches with other players. This would ideally create kind of a bell curve, with players of identical skill levels being paired up most often, with the likelihood decreasing quickly as skill-levels differ.
  12. Quote:Original post by Eelco Civ5 has the advantage of being able to switch to oldschool 2d graphics, which runs blazingly fast on an i3 without graphics card. I'm really glad you pointed that out; someone in our group had suggested Civ 3 - we had all assumed that IV and V would need heavier graphics cards. The fact that Civ5 has a "2d no-frills" mode may just make Civ5 a contender in our list.
  13. Hey all; Some of my office-mates and I are in search of a multiplayer video game that we can set up on a VM at work, and take turns playing. In particular, we'd like to share remote access to a turn-based strategy game. Something laid-back that we can stretch out for days. Ideally, one of us could just take their turn, log out of the remote desktop, and email the next person in line, to notify them of their turn. In order for something like this to work, the game would have fill the following requirements: -No 3D acceleration - this would be running on a VM over Remote Desktop, so intense graphics would be too much. -Turn-based multiplayer on a single computer. -Slow pace - each office-mate might take only a single turn in a day, depending on how busy we are. Alternatively, we've considered the possibility of a game which uses a server/clients structure. A game like this could have more intense graphics, as our work machines have plenty of horsepower. But we would need to be able to connect/disconnect out clients at will - we would connect just long enough to take our turns, and then exit the game. One last option would be a web-based game - something we could access with our browsers or a java client, over our corporate network. Give these 3 different approaches, can anyone suggest some games that would fit into one of those categories? Thanks, -Brian
  14. Hey guys - I am working on a project that consists of a .NET UI, which makes calls to a C++/CLI dll, which in turn makes calls to a third-party COM dll (which in turn links against some other 3rd-party lib files... ugh). I've installed and tested this application on Windows XP and Windows Vista 32-bit versions. When I tried to run the app on Windows 7 x64, I get an "BlahBlahApp has stopped working". The error details point to "KERNELBASE.dll" as the fault module, and the exception code is e0434f4d. With a program compiled for 32-bit Windows, shouldn't it "just run" as long as the appropriate VC++ Runtime is also installed? Has anyone else struggled with this type of problem in the past, and can suggest some possible solutions?
  15. BTownTKD

    Sharing code between multiple projects

    I suspect you're programming in C++, and everyone assumed it was C#. The "Add as Link" option will only show up in C# (and maybe VB.NET) projects. Normally when you add a file to a project in C#, it makes a copy of that file in your project directory. Selecting "Add as link" uses the path to the original file, instead. Thus you can use a single common source file in multiple projects by using the "Add as link" option. In C++, it doesn't automatically make a copy in your project folder; it simply stores the relative path to the original file. So, just adding the file to your project is sufficient (and the "Add as link" option doesn't appear, because it's redundant).
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!