|
Sorry if my post was unclear... here's a post I made on MSDN.
When I tried creating the following structure...
<structlayout(layoutkind.explicit, size:="1500)"> Structure TestStruct
<fieldoffset(33), marshalas(unmanagedtype.byvalarray,="" sizeconst:="17)"> Public Test As Char()
End Structure
I receive the following Exception...
Could not load type 'TestStruct' from assembly 'Test01, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 33 that is incorrectly aligned or overlapped by a non-object field.
This structure was creating in the Form Class with no other types in it... I have no idea what is going on here but it allows me to create this array at certain offsets but not others for some reason.
-- To repoduce...
Create the structure above in a new VB.NET Windows Application. Create the structure in the main class for the form... here's all of the code in my Form's Class using everything as default...
Imports System.Runtime.InteropServices
Public Class Form1
<structlayout(layoutkind.explicit, size:="1500)"> Structure TestStruct
<fieldoffset(33), marshalas(unmanagedtype.byvalarray,="" sizeconst:="17)"> Public Test As Char()
End Structure
Dim TestStructInstances As TestStruct
End Class
-Xtek
|
|
|
|
|
This is because the field packing boundry falls, by default in a managed structure, on every 8 bytes. Your field offsets don't work because they don't fall on 8 byte intervals (0, 8, 16, 24, 32, ...). If you're going to use Layoutkind.Sequential, you might want to take a look at the StructLayoutAttribute.Pack[^] attribute to go along with it.
But, your field sizes and the offsets you've specified don't allow for Sequential to be used. Your field sizes and offsets are demanding an Explicit layout.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Oops... again my stuff got parsed because of carrot tags. I'll repost my last one... I was using Explicity and it didn't change anything.
-Xtek
|
|
|
|
|
When you report the code, there is a checkbox under the message window that says "Ignore HTML tags in this message". Check it before you click Post Message.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Microsoft is looking into it now...
Edited by Microsoft on 2005-12-28 at 17:34:10
I've sent this to the CLR team so that they take a look.
I think you can work around the problem by declaring your type as a class instead of a structure.
Abel Valadez
VB Dev Team
|
|
|
|
|
Is it possible to kill a thread from a method which it is running?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
If you mean that function A is the threaded function and stopping it from within function A then yes. You can get the threading object by using System.Threading.Thread.CurrentThread.
On the object returned you can then call the Abort function. This will cause the thread to stop working.
|
|
|
|
|
I tried doing it but it threw a Thread is aborting exception. Is this natural?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Yes this is the normal behavior, this way you are able to clean up some memory if need be.
|
|
|
|
|
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
The best way to kill a thread is to simply return from the thread function. In your case, you say that you want to kill the thread from within a method that it's running, so I'd suggest simply unwinding the function stack and returning.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote: unwinding the function stack and returning.
Could you explain please?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Well, just break out of the loop if you have one and return gracefully. Something like
void ThreadFunc()
{
while (someCondition)
{
if (threadAbort)
break;
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Having used a MonthCalendar control in my project, I encountered a problem about a change in its size when I open my codes in another computer which has a different resolution. I try to use the Locked property, but unfornately it doesn't work at all. Only width size of it changes. So, how can I fix this problem? If it's possible I want to keep its size fixed for all machine. Thanks a lot for whatever suggestion! Merry X'mas. Happy New Year!
|
|
|
|
|
I have one problem.
How to read yahoo address book. if u provide me source code.
Plz any one one help me for this query....
Ashsih
|
|
|
|
|
You should contact Yahoo! asking them for the API you need to do this.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
Please excuse my frustration, but how the heck do you get an IServiceProvider interface in a .net windows form for the web browser?
I've used various versions of this to no avail...
Guid g = new Guid( "6d5140c1-7436-11ce-8034-00aa006009fa" );
IntPtr ipDoc = Marshal.GetIUnknownForObject( axWebBrowser1.Document);
IntPtr ipSP;
object obj;
Marshal.QueryInterface(ipDoc, ref g, out ipSP);
The IntPtr that comes back is the same as that I passed in for the document but no ServiceProvider.
I can get it just fine in an MFC app but there is some kind of a problem on the .Net side.
In fact, I can't seem to get any interface with Marshal.QueryInterface...
-- modified at 8:28 Thursday 22nd December, 2005
|
|
|
|
|
Never mind, I got it. (You have to define the IServiceProvider idl, or whatever the hell that COM thingey is called, in your own namespace so that it doesn't clash with System.IServiceProvider )
"Patriotism is the first refuge of a patriot."
|
|
|
|
|
I have a problem and I hope someone helps me fast...
Platform : Windows.
Language : C#
I have created two classes.Both these class are in a dll file The Class First is an internal class and the class Second has public functions which can be used by a client(.exe). Now the class Second contains an object of the first class.
First f = new First() ;
Also the class First raises some events which are captured by the class Second.
f.Hi += new hi() ;
Now i want, the client (.exe) to catch these events raised by the class First so what i am doing in class second is
private void hi()<br />
{<br />
RaiseHiEventforClassSecond()<br />
}
Now this event raised by Second is being caught by the client. So what is happening is
The event is being raised by First and the notification should go to client(.exe) but Second is in the middle. Also the user will not be able to make an instance of the class First in his (.exe) because First is an internal class. So Second is just passing the event from the first to client(.exe) by capturing the event and raising it again.
Now please don't ask me why I am doing this? Just that it is a requirement. Is my method OK or is there a better way of doing this???
Thanks,
Bikash Rai
|
|
|
|
|
My opinion? That's totally ok.
You should just consider taking .Net conventions into account:
1. Delegates for events should be declared like this: void MyDelegate(object sender, MyEventArgs args)
2. Event raising methods should be declared like this: protected virtual void OnMyEvent(MyEventArgs args) {}
|
|
|
|
|
Thanks Robert... Will keep the conventions in mind.
Bikash Rai
|
|
|
|
|
Import yahoo address book in .net application then what are API responsible for this.
Can you provide me open source code for import yahoo address book.
|
|
|
|
|
Please don't repost question - people will answer you if they know the answer. Reposting the same question just 4 or 5 posts apart will more likely irritate people.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
Probably no-one answered you before because there is no API for this.
Unless Yahoo has some sort of service to export this stuff into a file for you, but I doubt it. I haven't seen anything on it...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All,
I'm using Whidbey Beta 2, and I can't find the Solution Configurations drop-down anywhere.
Under Tools – Options – Projects and Solutions – General, there are options
Always show solution and Show advanced build configurations.
The Show advanced build configurations includes the Configuration Manager and the Solution Configurations and Solution Platforms combo box on the standard toolbar.
I have checked both the options still combobox is missing in the standard toolbar.
The only way I see to change to Release mode is to open the Configuration Manager from Build menu.
I've tried customizing the toolbars to add it, but there's nothing under the Build list
On Standard toolbar in VS2003 we use to have "Solution Configurations", which is missing in whidbey.
Any idea why it's missing now? Using which toolbar we can get it?
Please help.
Hiral
|
|
|
|