|
It is impossible to guess what is happening. You will need to use your debugger to gather more information.
|
|
|
|
|
Ok let me gather more information in detail, then i will get back to you.
For now thank you for helping me.
Have a nice day.
|
|
|
|
|
[Marking as NEWS - this is not a question but this is an appropriate forum IMO]
If you develop in C++/CLI with Visual Studio 2017, beware that update 15.9.6 introduced a very bad codegen bug. C++/CLI apps will crash if you use /std:c++17 or /std:c++latest. The workaround is to drop back to C++14 language support.
Here's the issue if you care to vote.
Again, this is FYI as it has cost me multiple days of work diagnosing why our application suddenly stopped working.
John
|
|
|
|
|
Hi,
I am working on some examples of my own and now looking to include a new class for my Banking transactions.
Seems like I am doing something in the wrong place etc.
I typed in the new code ahead of the standard code created by Visual Studio (17) (I didn't add an item). The information I wanted to create appears in the right hand window CLASS VIEW but I get the errors.
using System.Windows.Forms;
public class transactiondata
{
public DateTime transDT;
public string transtext;
public double transRECD;
public double transPAID;
public string transFlag;
}
public transactiondata(DateTime transDT, string transtext, double transRECD, double transPAID, string transFlag)
{
this.transDT = transDT;
this.transtext = transtext;
this.transRECD = transRECD;
this.transPAID = transPAID;
this.transFlag = transFlag;
return;
}
namespace Santander01
{
public partial class Form1 : Form
{
public Form1()
CLASS VIEW
shows the class and items above
THE ERROR
1>------ Build started: Project: Santander01, Configuration: Debug Any CPU ------
1>C:\Users\HOME\Documents\Visual Studio 2017\Projects\Santander01\Santander01\Form1.cs(19,8,19,23): error CS0116: A namespace cannot directly contain members such as fields or methods
1>C:\Users\HOME\Documents\Visual Studio 2017\Projects\Santander01\Santander01\For
Any help appreciated
|
|
|
|
|
You have terminated the class definition too early; the constructor is not inside it. Move the closing brace from where it is now, to the line following the end of the constructor block.
|
|
|
|
|
C# questions should be posted in the C# forum[^].
You've posted this in the "Managed C++/CLI" forum, which is nothing to do with C#.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Maybe he though that in the CodeProject numbering system, C++/CLI = C# .
|
|
|
|
|
I am trying to build some simple examples as part of my learning process.
I have created a form which includes the dateTimePicker and tried several combinations which have failed. The output initially displays time as HH:MM:00 and only dis[plays correct time when I include
...AddHours(0)...
I'd like to format - say
"MMMM dd, yyyy - dddd"
My standard output is
20/02/2019 00:00:00
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
String ^myText = "1&2-END";
dateTimePicker2->CustomFormat = "MMMM dd, yyyy - dddd";
dateTimePicker2->Value = DateTime::Now.AddDays(+30).Date;
myText = myText + "\r\n" + dateTimePicker2->Value;
dateTimePicker2->Value = DateTime::Now.AddDays(+30).AddHours(0);
myText = myText + "\r\n" + dateTimePicker2->Value;
myText= myText + "\r\n" + "& 3 -END";
myTB2->Text = myText;
}
I am using Visual Studio 2017, C++/CLi, W10 Professional
Guess I am missing some declaration - I have in .cpp
#include "MyFirstForm.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace System;
using namespace System::Windows::Forms;
using namespace System::IO;
[STAThreadAttribute]
Any help appreciated.
Looks like great way to develop FORM & C++ based programs
|
|
|
|
|
|
Hi & many thanks for your response....however
I added the following:-
dateTimePicker2->Value = DateTime::Now.AddDays(1);
MessageBox::Show(dateTimePicker2.ToString());
myTB2->Text = myText;
and failed to complie with the following error - is this what you meant.
When I follow your link it refers to C# whereas I am working with C##.
Severity Code Description Project File Line Suppression State
Error C2228 left of '.ToString' must have class/struct/union Project1 c:\users\home\documents\visual studio 2017\projects\project1\project1\myfirstform.h 335
Error (active) E0153 expression must have class type Project1 C:\Users\HOME\Documents\Visual Studio 2017\Projects\Project1\Project1\MyFirstForm.h 336
|
|
|
|
|
dateTimePicker2->Value = DateTime::Now.AddDays(1);
MessageBox::Show(dateTimePicker2.ToString());
|
|
|
|
|
Thanks again,
Apologies - but really struggling with this one
MessageBox::Show(dateTimePicker2->ToString());
MessageBox::Show(dateTimePicker2->ToString(), "MMMM dd, yyyy - dddd");
Both lines of code show same results -
System.Windows.Forms.DateTimePicker, Value: 22/01/2019 14:26:18
whereas I'd just like to see January 22, 2019 and in this case no time
|
|
|
|
|
Sorry, my mistake. You need to call ToString on the Value property like:
MessageBox::Show(dateTimePicker2->Value.ToString("MMMM dd, yyyy - dddd"));
|
|
|
|
|
Many , many thanks - your swift responses appreciated enormously
Works fine
|
|
|
|
|
Happy to help. I don't know what your background is, but if you are just starting out you might find C# a better choice than C++/CLI.
|
|
|
|
|
Many thanks.
Very mixed background
Wrote first programs in 60's (machine code, user code, Fortran, Algol & many more)
Moved into IT sales / management
Have developed Forex applications in MT4 which is sort of C based
Started with this C++ / CLi on Saturday - so sort of making progress
I've fought shy of 'understanding' the ins / outs of C
Now retired and need to keep brain cells stimulated !
Thanks for support & comments and will read around
|
|
|
|
|
Since you have only just started with C++/CLI, my advice would be to stop now and switch to C#. It is so much better for this sort of application, and the learning curve is not as bad as it may at first appear. There is a great free starter document at .NET Book Zero[^] which you can work through fairly quickly. Like you, I am retired and followed this route myself, so I am far from being a C# expert, but I can code simple applications without too much trouble.
|
|
|
|
|
hi guys love this site so helpful. i have a c++/cli program im writing. im not going to post no code at this time cause i hope my problem can be solved with just a explanation. in my main form i run some code that controls a pic chip that runs some servo motors, communicating through the serial port. all runs fine. the problem im having is that well you know serial port is on another thread. so i use invoke and run a data received method on the ui. now that has a switch statement that may call some other functions in my ui thread that all works fine until one of the functions actually needs some input from the serialport. but i dont get any data in until the invoke completes. i tryed to run it with begininvoke which seems to work fine for the serialport but the ui doesnt update the form at all during the invoktion. so i thought i would just try to have the datareceived funtion fire an event on the ui. but then i get a crossthread error. maybe im not doing the event correctlly im still trying to get my head around delegates and events. question? does this seem reasonable? what i need to do is get that serialport freed up so that it can receive data again while the ui runs its code. Please bear with me im learning. and i have been reading post after post about threads, delegates, and events. ive problebly seen the answer and didnt know it. ill be happy to read im just not sure of the correct implementation. and im writing this in c++/cli cause i copied some code from an old borland c++ program. thanks in advance. yes i could post some code but ill have to clean it up first and pick out important parts right now its quite sizable.
|
|
|
|
|
Unfortunately your manner to describe the problem, you need the assistance with, does not help to help you.
Or, maybe your keyboard failed to work properly (so neither Shift, nor Caps Lock, nor Enter key does work?)
|
|
|
|
|
My apologies:
Let me try this again. I'm wondering if there is a way to free my serial port thread after i invoke to my UI thread.
Once i Invoke from the Data Received event on the Serial port Thread to a receive function on the UI thread, my switch statement in the receive function may call a function that sends data to the pic program. Now the pic responds immediately but the data doesn't appear cause the invoke method hasn't quite exited yet. any suggestions would be Appreciated.
|
|
|
|
|
|
This is not the place for such messages.
|
|
|
|
|
What?? This is the Managed C++/CLI forum. This crash directly affects C++/CLI code. I'd think anyone that cares about successfully coding in C++/CLI will care about this. Thus, the post.
|
|
|
|
|
Hi
I am working on a C++ Project in which i am using some third party SDK to read some data. Some times few API's in that third party SDK are getting crashed such that my program getting terminated\crash.
So, instead of crash i want to handle those exceptions in the third party API's. May i know how to do handle them. I am using Visual studio 2015 and used exception handling too but unable to catch the exceptions thrown by third party API's.
Regards
Sampath
|
|
|
|
|
Contact the owners of the library for help. Unless you know exactly where the exceptions occur, and what they are caused by, you will find it very difficult to gather any meaningful information.
|
|
|
|