.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to best handle different packing in 32 bit v.s. 64 bit?

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :.NET Framework

I've got some code which uses FDINOTIFICATION (in fdi.h) via interop.  The problem I ran into is that fdi.h sets the packing to 4 for non Win64, which I guess means it's the default (8) for Win64.  What's the best way to handle this on the managed side?  I'm currently doing this:

#if WIN64
 [StructLayout(LayoutKind.Sequential, Pack=8, CharSet=CharSet.Ansi)]
 [StructLayout(LayoutKind.Sequential, Pack=4, CharSet=CharSet.Ansi)]
 internal class NOTIFICATION

But this means that I need two different versions of my assembly, one for 32 bit and one for 64 bit.  I was hoping I could do the following so that a single assembly would work for both platforms:

 [StructLayout(LayoutKind.Sequential, Pack=sizeof(IntPtr), CharSet=CharSet.Ansi)]
 internal class NOTIFICATION

But that didn't work.



View Complete Post

More Related Resource Links

Transactions: Build Scalable Systems That Handle Failure Without Losing Data


Systems that handle failure without losing data are elusive. Learn how to achieve systems that are both scalable and robust.

Udi Dahan

MSDN Magazine July 2008

C++ Q&A: Finding a Win32 Handle, HTML in CHtmlCtrl


This month Paul DiLascia discusses how to find windows with GetLastChild and outputting HTML with a C++ procedure equivalent to document.write.

Paul DiLascia

MSDN Magazine August 2003

COM: Handle Late-bound Events within Visual Basic Using an ATL Bridge


Since a Visual Basic client doesn't handle events directly from late-bound COM objects, it needs some way to capture all the events and parameters launched by any COM object server instantiated at runtime and not known at design time. This article explains how to build a bridge component that does just that. The bridge component transmits the intercepted event data back to the Visual Basic client using another supporting COM object that is capable of holding event data and attributes. The Visual Basic client receives the notification from the bridge and extracts all the information relative to the event from the supporting object.

Carlo Randone

MSDN Magazine March 2001

How to handle Active and inactive items in the dropdownlist?


It is a general ASP.NET questions. Many times some items in dropdownlist will become inactive (retired)or active again. It is easy to handle in the new records which use only currently active items. But how to handle the inactive items which need to be used to show history records. It bothered me a long time, not sure how to solve this problem efficiently.


Multiple forms on the same page MVC2: how to handle (including validation from model)



It should be simple; although I'm having a hard time to figure out the best way to do it. I've MVC2 pages with multiple forms on the same page having different functionalities.

What's the best way to handle this; including the MVC2 way of validation from the model?


Timeout Property, how do i handle timeout


iam using technique mentioned in this tutorial

i also added this AsyncTimeout="300" in page element


the query is correct, how do i handle timeout

Error in: searchresumes.aspx

searchquery was countryid=1 and hide='N' and stateid='34' and cityid='347' and industryid='7' and jobcategoryid='3' and totalexp>=0 and totalexp<=1 and CONTAINS(entirecv, '"Freshers" or "call+center" or "bpo" or "kpo"')

- Hide quoted text -

Error Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavi

How to handle null while converting from my datatable to List<> using LINQ


I am converting my datatable to LISt using LINQ
how do I handle nulls coming from database

List<Port> portDetails = new List<Port>();
DataTable dt = ds.Tables[0];               
portDetails = (from q in dt.AsEnumerable()
select new Port
PortCode = q.Field<string>("Code"),
ExtCode = q.Field<string>("Nb"),
Name = q.Field<string>("Name"))

In the above query if Code is null I do not want property
portcode to be set to the value it should only set if it is
not null or not blank 
PortCode = q.Field<string>("Code"),

What should be syntax
I was trying somethign like this which doesnt work
Portcode = q.Field<bool>("Code") == null ? null : q.Field<bool>("Code")


How to handle this format in c # 1000/1

Hi. I have problem. If i have data in sql table in this format " 1000/1 " or "2000/2" how i can check if value exist in table + to check what is last record in the table or what is max value in the table? 1000  Connex Y NULL 2000\2   Dan NULL NULL 3000\3   Eged NULL NULL 4000\4   Veolia NULL NULL if I use This code  i get this error " Conversion failed when converting the varchar value '2000\2' to data type int" I need to convert the value only after to check it?   using (SqlCommand cmd = new SqlCommand(strSQL, cn))    {      int intCountExisting = (int)cmd.ExecuteScalar();      if (intCountExisting > 0)       MessageBox.Show("ID Already exists!");    }

XMLSerializer don't handle mixed contents properly

mixed content model allows a combination of text and elements in the XML document. we use .net xmlserializer to serialize/deserialize the XML. XmlSerializer don't handle mixed content properly. XmlSerializer handles mixed content models to a degree. XmlSerializer add the text in the xml document, but the position of text is not exactly where they appeared in the original XML document. Let's take a example here is original xml <employee xmlns="http://example.org/xmlserializer">   here is some text...   <id>333-33-3333</id>   here is some more...   <name>Bob Smith</name>   and here is even more... </employee> We deserialize above xml using the xmlserializer then we serialize it back into xml. Now xml document is changed as follows <employee xmlns="http://example.org/xmlserializer">    <id>333-33-3333</id>   <name>Bob Smith</name>   here is some text...   here is some more...    and here is even more... </employee> You see the position of text is changed. I have seen the Microsoft code to serialize/deserialize the xml through reflector. They put text in a string array but position is not saved. Is there any solution or workaround? I don't want to parse the xml by xmlReader. I want fix in the Microsoft generated classes that ar

handle missing types during deserialization

I have situations where I may have a type reference in the object graph that is no longer available because it has been depricated. These are objects defined outside the control of my serialization API. I need the deserializer to just ignore these objects and move on without erroring out with: "Unable to find assembly 'MyMissingAssembly, Version=, Culture=neutral, PublicKeyToken=null'." My question is not why the error is occuring. I understand why. But how do I handle this error gracefully, have the missing types skipped, and continue deserializing the rest of the object graph? I have experimented returning a dummy class through the VersionDeserializationBinder.BindToType() method so that I can do type substitution with types I control. This works but I need a way to discriminate for which types I should do this for. So I need to know if the deserializer has access to the type in question before it attemts to deserialize the object. If only it could tell me it can't find it before it throws the error.  

Best approach to handle concurrent requests in winforms

I have a windows client application which would be used many users. This application submit requests to run a workflow (note that this is not a WWF or WCF service, its a class library thats gonna do some processing). What would be the best approach to code this? Would processing each request on a separate thread be a correct way? I am a newbie at this. PLease help. Thanks!

Best approach to handle concurrent requests in winforms

I have a windows client application which would be used many users. This application submit requests to run a workflow (note that this is not a WWF or WCF service, its a class library thats gonna do some processing). What would be the best approach to code this? Would processing each request on a separate thread be a correct way? I am a newbie at this. PLease help. Thanks!   

How to handle *many* date fields?

I have put together a cube for auto loan analysis. It is populated via monthly snapshots. There are many actions taken on these loans that have a date stamp associated with them (repossess/resell/refinance, etc.). These fields are on each row and only populated if utilized, else NULL. In the design of the cube, all of these fields were specified as being associated with date dimensions. Now that I am actually building this thing out, my date dimension is aliased (role playing) 15 times! This seems ridiculous to me as many of these date fields are not useful for analysis, per se. Primarily the analysts need the ability to filter based off of them. Ie. Display measures [x],[x1] in a pivot table where reposession date > '[Jan 2005], etc. They use excel 2007 for analysis. Is there another way to handle all of these auxiliary/sparsely populated dates besides creating dimensions for them?   Thanks for your help!

Windows form.Handle

I need to know the equivalent code for ASP.Net as like:In my windows application I write :Form frm = new Form();IntPtr hwndp = frm.Handle;Now my question is how can I achieve this value through ASP.Net code?

Table Group can not handle more data

Hi All,   I've a report and from Query, I am generating all serial numbers with comma as seperation. Now I've got an error with serial numbers around 200.   I'm generating invoices through SSIS process and it failed and when I tried to figure out the reason, I found out this. And I tried to Save the Preview in PDF and it gave me the error   An Error Occured during local report processing. Index was out of range. Must be non-negative and less than the size of the collection. Parameter Name : index   I tried to remove that serial_no group from the table, and it worked perfect (but i want that serial_number and thats MUST field in report.) And its working for all other reports. just not for something like BIG report with 4 products each have more than 200 quantities (means 200 serial numbers each)   (Also it will retrive all the data in preivew section. but nothing if you select PRINT PREVIEW)   Any suggestions or ideas whats going on. Thanks in Advance.  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend