|
Something else I noticed right off the bat:
[ClassInterface(ClassInterfaceType.AutoDual)] NEVER use this. Auto-generated class interfaces are the worst thing ever added to the Framework, in my opinion. If you know anything about COM, you should agree. While .NET isn't prone to problems caused my moving members around, native code (like the COM infrastructure) is. Always declare your class interfaces explicitly, always use a hard-coded, unchanging guid via the GuidAttribute on both your class and COM-exposed interfaces, and never change published interfaces. Derive new ones, implement those as the first interface of your class (which the CLR treats as your class interface when you use ClassInterfaceType.None with the ClassInterfaceAttribute ) successively when releasing new interfaces. This is how you'd do it in COM and need to replicate that behavior in .NET. While .NET doesn't care, COM sees a different story and clients will start breaking left and right. That is not the problem at hand, however.
If you are exposing this to COM and using your class, the make sure you're releasing the object by calling IUnknown::Release in your native code. If not, the DLL is not unloaded and will be in use (soft-locked).
And once again, you should not sub-class the Window how you're currently doing it. This is most likely causing the problem. Simply override WndProc (just like you'd do on any other Windows Forms control (since most encapsulates native Common Controls) when a particular message isn't handled in a .NET-friendly manner. Catch the WM_PAINT message like in the following and handle that however is necessary:
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_PAINT)
{
}
base.WndProc(ref m);
} I very much doubt the Framework is expecting you to sub-class the Windows by re-assigning its window procedure. Just don't. You're performing extra work - and putting extra work on the CPU for marshaling - when it's not necessary. The window procedure is already encapsulated and exposed for you: NativeWindow.WndProc .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks a lot for your extensive explication. I will google around in the coming time to get some code to make the release-call (and the rest) work, and look for some extra info on using com.
I hope I can get back to you if I do not (fully) succeed.
regards,
Stefan.
|
|
|
|
|
I have a dataTable tbl. If my app. start it's emty. I can fill it manually but i can also save the table of the last session. I do that with XmlWrite().
To load the table i use the XmlRead() method. After I done this tbl_ColumnChanged stops raising events although my Comlumns are changing.
I'm debugging for a while to find out the raison why it stops raising event but it has not been very succesfull till now. Can someone tell me why?
Dogan
|
|
|
|
|
i've a problem with the code below on how i've used the structure,binary files and some of the functions!
the code:
/* bus reservation system*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXSEAT 45
#define FILE1 fptr1;
#define FILE2 fptr2;
struct info {
char name[15];
char date[8];
char dest[15];
int seat;
float amount;
char mark;
};struct info record;
void ticket();
void sold_seat();
void reservation();
void thank_u();
void bus_fare();
void bus_report();
void check_it();
int q,rseat;
main()
{
int op;
START:printf("1:MAKE RESERVATION\n");
printf("2:SELL A TICKET\n");
printf("3:EXIT\n");
printf("enter your choice:\n");
scanf("%d",&op);
switch(op)
{case 1:{reservation();}
break;
case 2:{ticket();}
break;
case 3:exit(0);
break;
default:{printf("\nenter listed choice!\n");
goto START;
break; }}
return 0;
}
void reservation()
{
FILE*fptr1,*fptr2;
char name[15],date[15],dest[15],bname[15];
int i,seat;
fptr1=fopen("bus.txt","rb");
fptr2=fopen("user.txt","wb");
while(!feof(fptr1))
printf("\nenter bus name:\n");
scanf("%s",bname);
fptr1=fopen("bus.txt","rb");
if (fptr1==NULL)
printf("\nenter name:\n");
scanf("%s",(record).name);
printf("\nenter your destination:\n");
scanf("%s",(record).dest);
printf("\ndate:\n");
scanf("%s",(record).date);
check_it();
fptr2=fopen("user.txt","rb+");
fscanf(fptr1,"%s%d",(record).name,&seat);
fclose(fptr1);
fclose(fptr2); thank_u();
}
void check_it()
{
FILE*fptr2;
int seat,rseat,pseat,n;
fptr2=fopen("user.txt","rb");
n=0;
while(!feof(fptr2))
{START: printf("enter seat no:\n");
scanf("%d",&seat);
if(seat==seat)
{printf("seat taken\n""pick another seat\n");
goto START; }
else
{scanf("%d",&seat);}
rseat=n+1;
pseat=MAXSEAT-rseat;
if(n=MAXSEAT)
{printf("bus full");
reservation();}
n++;}
fclose(fptr2);
}
void ticket()
{
FILE*fptr1;
char mark,name[15],bname[15];
int seat;
fptr1=fopen("bus.txt","rb");
printf("enter bus name:\n");
scanf("%s",bname);
while(!feof(fptr1))
if (fptr1=fopen("bus.txt","rb+")==NULL)
{reservation();
fclose(fptr1);}
else
{printf("enter name:\n");
scanf("%s",name);
printf("enter seat no:");
scanf("%d",&seat);
if(strcmp((record).name,name)&&(record.seat,seat)==0)
{{printf("seat paid??(Y/N)\n");
scanf("%c",mark);}
if(mark='Y' || 'y')
{bus_fare();} }
else
{printf("\nthe seat is reserved!\n");}
}fclose(fptr1); thank_u();
}
void thank_u()
{
printf("\n***THANK YOU***\n");
}
void bus_fare()
{
float amount,sum;
sold_seat();
printf("\nenter amount paid:\n");
scanf("%f",&amount);
sum=q*amount;
printf("\ntotal revenue:%f\n",sum);
}
void bus_report()
{
check_it();
sold_seat();
bus_fare();
}
void sold_seat()
{
int q,i;
char mark;
q=0;
for(i=1;i<=45;i++)
if(mark=='Y'||'y')
{q=q+1;
printf("\nseats reserved and tickets sold:%d\n",q);}
check_it();
printf("\nseats reserved and tickets not sold:%d\n",rseat-q);
printf("\nseats not reserved:\n",MAXSEAT-rseat);
}
project was:
In this project you will develop a program that can be used by a bus company to
manage reservations of potential travellers to the buses operated by the company.
When invoked the program should present the user with two choices and let user
choose by inputting corresponding number:
1.Make a reservation
2.Sell a ticket.
If user choose (1) the program should,
1.Prompt user to input Bus name and find the file with that name, if not found create
a binary file with given name for keeping reservations for that bus.
2.Create a structure with all information needed to record a reservation.
3.Check for consistency that the seat is not taken already and the bus is not full.
4.Write the reservation into the binary file for chosen bus maintaining consistency.
5.Thank the user and exit.
If user choose (2) the program should,
1.Ask the user to input the name of bus in which reservation was previously made.
2.If the bus file does not exist, inform the user of the problem and repeat step 1.
3.Ask user input name and seat number reserved
4.If name and seat number are correct, mark the seat as sold and record amount of
money paid for the seat.
5.Finally the program should thank the user for using the program and display a
pretty report showing the current status of chosen bus in terms of which seats are
reserved, which ones for which the ticket is sold and total revenue collected so far.
thanks.
|
|
|
|
|
505 wrote:
i've a problem with the code below on how i've used the structure,binary files and some of the functions!
What would the problem be? You cannot just say "I've a problem..." and expect people to know what it is. Heck! We don't even know what your code is supposed to do - And no, we are not going to trawl through the code to figure out what it is supposed to do.
Next, this code appears to be C++. You should post it in a C++ forum. This forum is for C#. You will have a better chance of someone helping you if you post your question in the correct forum.
Do you want to know more?
WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums
|
|
|
|
|
Hi All,
I've already sent this problem and was replied by some senior software engineer of microsoft but I could not be clarified. Let me elaborate the problem again:
I've populated a dataset object with records from multiple tables by executing a stored procedure(in which I've used the joining of the tables). Then I bound a datagrid with this dataset. When user made the changes, is there any way that these changes can be accomodated in the original database tables(because there are more than one tables hence I feel problem in propagating these changes). Can anyone plz suggest me some solution or the way with which this can be dealt with?
I shall be very thankful
Regards
|
|
|
|
|
The CommandBuilder will not be able to generate the INSERT, DELETE and UPDATE commands of a multiple table query. U will have to do this manually.
The best way is to create parametrized commands:
As an example, imagine we have the following query: "SELECT T1.A,T1.B, T1.C, T2.D FROM T1,T2 WHERE T2.C=T1.C" being T1.A the primary key of table T1.
We create a dataadapter and fill up our DataSet:
myDataAdapter.Fill(myDataSet,"myTable")
For sake of simplicity, let us say that ur datagrid is bound to the table resulting of this query and shows fields A,B, C and D, but only A, B and C can be edited->thus we only have to propagate changes back to table T1. (Propagating to T2 wouldnt be a problem, but lets keep this as short as posible).
We would create our update, delete and insert commands as follows:
INSERT COMMAND: INSERT INTO T1(A,B,C) VALUES(@A,@B,@C)
Parameters would be mapped to DataColumns A,B and C and RowVersion would be Current.
DELETE COMMAND: DELETE FROM T1 WHERE T1.A=@A
Parameter would be mapped to DataColumn A and RowVersion would be Original.
UPDATE COMMAND: UPDATE T1 SET T1.A=@A_current, T1.B=@B, T1.C=@C WHERE T1.A=@A_original
Parameters would be mapped to DataColumns A,B,C and versions would be Current except the primarykey used in the Where statement which sould be Original.
Once created all commands, we would assign them to our dataadapter and to propagate changes back to the database we would execute:
myAdapter.Update(myDataSet,"myTable");
If your datagrid does not contain all the fields of ur table then pass along the default values in ur sql commands (no need of parameters in those cases).
U could also solve the problem using the dataTable.GetChanges([rowVersion]) method and iterating through all the modified rows and executing the necessary NonQueryCommands using the Update/Insert or Delete commands similar to the shown above depending on the RowState of the current row. This would be a better solution when propagating changes back to multiple tables as you would only have to iterate once throug ur modified rows in order to propagate changes to all afected tables (just run all the nonqueries to all the tables u need on each row).
|
|
|
|
|
|
Hi all,
1.I am a Singapore student working on my final year project. I am using DirectSound and C# to acquire .wav sound from a microphone output. But how do I show the waveform while acquiring it?
2. Is there anyone who can advice me on how to do video conferencing in C#? Any resources? I have searched many websites but don't seem to find one which can stream video and audio at the same time?
Many many thanks.
Eng Eng
|
|
|
|
|
Hi,
Basically a Command is nothing else than a Plugin, should mean that i would like to be able to write Commands which implement the ICommand interface and are stored in different assemblies, which are loaded at run time through a type loader.
I have a collection of Command's, let us call it my project file which i serialize trough the SoapFormatter.
So, now we have a project file which holds a command configuration set, now i would like to load this file again (later), but now it happens...
First i run my TypeLoader which loads the needed assemblies into the current AppDomain. Then my code tries to deserialize the soap file, it throws an exception saying that the needed assembly/type is not found, but ermz, my TypeLoader loaded the needed assembly...
Any hints? In my opinion it should work, because all assemblies are loaded during Deserialize, it's the same game like Serialize
myMsg.BehindDaKeys = "Jerry Maguire";
|
|
|
|
|
If I understood correctly, you aren't able to deserialize some previously SoapFormatted objects. Without some code, it's hard for us to guess what's wrong, but the most common serialization problem I see here is versioning, which can be solved by setting the AssemblyFormat property of the SoapFormatter to FormatterAssemblyStyle.Simple before serializing.
Yes, even I am blogging now!
|
|
|
|
|
System.Runtime.Serialization.SerializationException
Additional information: Parse Error, no assembly associated with Xml key a4:http://schemas.microsoft.com/clr/nsassem/Raccoom.Batch.Commands/Raccoom.Batch.Commands BuildCommand
myMsg.BehindDaKeys = "Jerry Maguire";
|
|
|
|
|
Hi Daniel,
I made shure that my assemblies always ware the same version number, no auto increment build numbers.
Now i found out that everything goes well if i copy the needed assembly into my bin directory.
myMsg.BehindDaKeys = "Jerry Maguire";
|
|
|
|
|
Hello,
I created a component with extended property in A WEB FORM! (not windows form).
the data is stored in hashtable.
problem:
the hashtable values are not added to the form after updating the extended property. meaning, in run-time the hashtable is empty.
for unknown reason, in web application, you should do something to make the hashtable values being added to the form.
how to do so?
many thanks,
Eran.
|
|
|
|
|
Hello,
I created a component with extended property in A WEB FORM! (not windows form).
the data is stored in hashtable.
problem:
the hashtable values are not added to the form after updating the extended property. meaning, in run-time the hashtable is empty.
for unknown reason, in web application, you should do something to make the hashtable stored.
how to do so ?
many thanks,
Eran.
i read that
|
|
|
|
|
Hello,
How to create dynamically multiples controls (progressBar) varies on item count of listbox.
Items elements vary.
Thanks
|
|
|
|
|
The same way as you would a static number or as the designer does it (take a look at your code-behind source file sometime for a Form or UserControl :
for (int i=0; i<listBox1.Items.Count; i++)
{
ProgressBar pb = new ProgressBar();
Controls.Add(pb);
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
i have a problem, it is a bit long explenation but please help...
this is very very annoying problem.
i created a component the implent the IExtenderProvider.
I have "binding" property which saves information of controls in an HashTable.
since the binding is a class, i use "ExpandableObjectConverter" to convert the value from string to object
When i add the binding propery to a control in a form, it seems to be fine.
BUT when i move to the "cs" file to see how it was added, i get the following error in the "task list" : "code generation for property Binding failed. Error was: 'key cannot be null. Parameter name key'" !?
the cs files remains as is without any modifications.
i tried to debug the design-time and saw that the values are added to my hashtable. offcurs not while run-time (it makes sense since nothing is being added to the cs file).
i don't have such a property named "key"...
Eran Sakal.
code attached :
[Category("Data"), Description("Define DataBinding on object")]
[DefaultValue("")]
public Binding GetBinding(Control extendee)
{
if (m_bindingCol.Contains(extendee.ID))
return (Binding)m_bindingCol[extendee.ID];
else // if not exist, create default value which is not added to the hash table
{
Binding binding = new Binding(null);
return binding;
}
}
public void SetBinding(Control extendee, object value)
{
Binding binding = value as Binding;
binding.Control = extendee;
if (binding.ObjectProperty == null)
m_bindingCol.Remove(extendee.ID);
else
{
// set default controlproperty if null
if (binding.ControlProperty == null)
binding.ControlProperty = (extendee is CheckBox) ? "Checked" : "Text";
if (binding.ObjectType == null)
binding.ObjectType = m_boundType;
// add to collection
if (m_bindingCol.Contains(extendee.ID))
m_bindingCol[extendee.ID] = binding;
else
m_bindingCol.Add(extendee.ID,binding);
}
}
|
|
|
|
|
|
How can I know which of my winforms are open?
Thanx
|
|
|
|
|
Do you want to know which are open or which are active, because there's a difference? Only one top-level window can be activated on the entire desktop at a time. If you want to get the active form in your application, then use the static Form.ActiveForm property.
If you want to know which windows are open, then you need to track your Form variables.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
Is there a way to find any of the managed directx dlls eg. microsoft.directx.dll if the user doesn't have the directx sdk installed?
Thanks
|
|
|
|
|
|
Basically on computers with directx 9c sdk installed there is a Microsoft.NET/ManagedDirectx directory in the windows directory which contains the directx dlls. Is there any way for users to access these without having the directx sdk installed?
thanks
|
|
|
|
|
thepersonof wrote:
Basically on computers with directx 9c sdk installed there is a Microsoft.NET/ManagedDirectx directory in the windows directory which contains the directx dlls. Is there any way for users to access these without having the directx sdk installed?
What to you mean by "access"?
If the files are on disk then yes, this folder has no special permissions on it.
If you need Managed DirectX to be on the system for your application to run then you need to install the DirectX redistributable with your application. The SDK is a Software Development Kit which has additional aids and documentation for developing software which your end users do not need. If this is what you mean the link I gave in my previous post will help you find the redistributable package.
Does this help?
Do you want to know more?
WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums
|
|
|
|
|