|
Hello all!
I am using a C# program and would like to generate the exe file from the source code. Can anyone provide some help. I look for msdn but not found.
Thanks All,
Tran Dung
|
|
|
|
|
I don't understand. Do you mean you want your program to compile an exe from source code ? The way to do this is to call the command line compiler.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes, I want my program to compile an exe file from source code.
or complie another program to make an exe file.
Can you provide some help.
Thank you very much.
Tran Dung
|
|
|
|
|
|
Thanks Christian Graus
Tran Dung
|
|
|
|
|
Any idea why I get a "An unhandled exception of type 'System.NullReferenceException' occurred in MyApp.exe. Additional information: Object reference not set to an instance of an object" on the last line of the following code? When I put WordApp.Selection in the Watch window, it says <undefined value="">. I copied this process right from the book. The app is early bound to Word.
public class ReplaceWord : IDisposable
{
private Word.Application WordApp=null;
object readOnly = false;
object isVisible = false;
object replaceAll = Word.WdReplace.wdReplaceAll;
object missing = System.Reflection.Missing.Value;
public ReplaceWord()
{
if (WordApp==null) WordApp = new Word.ApplicationClass();
}
public void SearchAndReplace( object fileName )
{
Word.Document aDoc = WordApp.Documents.Open(
ref fileName, ref missing,
ref readOnly, ref missing, ref missing,
ref missing,ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible,
ref missing, ref missing, ref missing );
//Move selection to the beginning of doc.
Object unit = Word.WdUnits.wdStory;
Object extend = Word.WdMovementType.wdMove;
WordApp.Selection.HomeKey(ref unit, ref extend);
Cliff Anderson
Lockheed Martin Corp.
|
|
|
|
|
When you get a System.NullReferenceException , typically you are trying to access a field, property method, event of an object that is null. Have you tried steping through the code, if it occurs on the last line, it is possible that either WordApp or Selection could be null.
|
|
|
|
|
How can i protect my password for connection to the Microsoft Access Database?
Can i use Store Procedure with Access Database?
|
|
|
|
|
Sasuko wrote: Can i use Store Procedure with Access Database?
I believe that is possible, nowadays.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Access can't use Stored Procedures... that I know. You can only create querys (sort of like views) but that's about it. Can you use macros or modules as stored procedures? I'm just thinking I don't really have an idea.
daniero
|
|
|
|
|
I don't use it, but I've been assured that SP exist in the newer versions.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Roger, I just created an access file with office 2003, and didn't see anything related to stored procedures, may be they're just not straigh out visible there.
As for protecting password... are you using VS 2005? if so, there's a way to encrypt information into the web.config file. If I find information I'll tell you, but it shouldn't be hard to find information about it.
daniero
|
|
|
|
|
[How can I protect my password for connection to MS Access database?]
Not too sure what you mean here, but I normally put use a config file with the user name and password encrypted. The code then decrypts the values and into the connection string.
Sorry, not sure if I answered that one properly
[Can I use Stored Procedure with Access Database?]
This really depends on the version of Access you are using. I think Access 2003 allows you to either use its Jet engine (I think they still call it that) or Msde (local SQL server). This is depends on how the Access database was setup.
If it was setup using Msde, then all linked tables and queries reference SQL server tables and stored procedures. However, if it was setup with the Jet engine, then it will be Access queries.
In both cases, if you are using ADO, then the queries can be treated as stored procedures in your ADO.Command object anyway. The restriction with the Access query is that you cant use things like return value, but both accept parameters.
If you are using an older version of Access then it uses the Access query and the Jet engine.
I hope this helps [anyone feel free to correct me if my memory has failed me with Access as it's been a little while since I used it]
Peter
|
|
|
|
|
Hi,
I have the following code in an unsafe section of code:
int scan0 = data.Scan0.ToInt32();
byte * colPixel;
byte * rowPixel;
byte innerColorB = innerColor.B;
byte innerColorG = innerColor.G;
byte innerColorR = innerColor.R;
byte innerColorA = innerColor.A;
int stride = data.Stride;
for (int y = 0; y < height; y ++)
{
rowPixel = (byte *)(scan0 + y * stride);
for (int x = 0; x < width; x++)
{
colPixel = rowPixel + 4 * x;
*colPixel = innerColorB;
*(colPixel + 1) = innerColorG;
*(colPixel + 2) = innerColorR;
*(colPixel + 3) = innerColorA;
}
}
I'm basically setting all pixels of a bitmap to a specified color. I know I could use the FillRectangle function but I don't want to .
My question is if anyone here might have an idea how this could be performed better/faster.
|
|
|
|
|
Robert Rohde wrote: int scan0 = data.Scan0.ToInt32();
I don't lint the look of this. I always turn it into a byte * from the get go. I'm not sure if C# will magically deal with 64 bit, where this code would be wrong.
I think the way I do it is faster, which is to create a byte * out of scan0, then keep adding to it as I go, instead of calculating the position every time. You should read my image processing articles on this site, they all do it the same way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for your help. Now it performes a bit better (although not really significant):
byte * p = (byte *)(void *)data.Scan0;
int nOffset = data.Stride - bitmap.Width * 4;
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
p[0] = innerColorB;
p[1] = innerColorG;
p[2] = innerColorR;
p[3] = innerColorA;
p += 4;
}
p += nOffset;
}
Isn't there a way to set a bunch of bytes in one step instead of having to move through each pixel? As I said the whole bitmap should be filled with one color. Is there a way to prepare a byte array or something containing all bytes for one row and than just copying it y times?
|
|
|
|
|
I've not found a memcpy type function or a memset, for that matter, in the framework. However, given that the color does not change, you could turn the RGBA values into an int, and then set it in one step for each pixel. nOffset will also be a multiple of 4, so you could set the pointer to be an int * all the way through, instead of having to cast it, just make sure you divide nOffset by 4 to match.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a class which wraps the mpr.dll functions that I've used in may applications before. But now I'm attempting to use them in a WebService and the WNetAddConnection2A fails everytime. Any known issue with using these method with Web Services ?
|
|
|
|
|
Of course it does! The ASPNET account that your webservice runs under, by default, doesn't have permissions to any other network resources. No permissions, no access and the call fails.
Either grant the ASPNET account permissions to the network resource you are trying to map to or create a user account that has those permissions and change the account your webservice runs under.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So even though I providing a username and password in the call to WNetAddConnection2A, I need to give permissions in order to even make the call ?
|
|
|
|
|
Does the account name you're providing have the appropriate rights to the network resource? Are you sure your using the correct name and password? Things can be a bit confusing in a domain environment and different in a workgroup.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, the account name I'm providing is the local administrator on that machine. I'm not using any domains at this point. The weird thing is that the function returns immediatly, it seems like there isn't even enough time for the remote machine to accept or reject the call.
|
|
|
|
|
Try changing the account that your web service is running under. I get the feeling that the ASPNET account doesn't have any network resource rights to make a connection to anything.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've already searched online for instructions on how to do this correctly and attempted it, but have been unable to do so. I've changed the ASPNET user password on both machines to the same password and given the account read/write access to the files. But even after I change the password field in the machine.config file the web server will not load the web service. The only way I get it to function properly is to run the aspnet_regiis.exe command to reset the password toa randomly generated one. Have you ever successfully change the ASPNET password ?
|
|
|
|
|
What are you changing the password for???? There's no reason to do it.
Create an account that your web service will run under and change it to that account in IIS.
On a second thought, why are you mapping a drive inside a web service? This drive mapping will disappear as soon as the current call to the web service returns.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|