I'm getting a build warning in the Output window of Visual Studio that states:
... warning : Fody/PropertyChanged: Unsupported signature for a On_PropertyName_Changed method: OnUsersChanged in MainWindowViewModel. You can suppress this warning with [SuppressPropertyChangedWarnings].
This is the method that is causing the error.
private void OnUsersChanged(object sender, NotifyCollectionChangedEventArgs e)
{
defaultChangeFactory.Current.OnCollectionChanged(this, "Users",
Users, e);
}
My question is where to put [SuppressPropertyChangedWarnings] to suppress the warning? I tried using [SuppressPropertyChangedWarnings] as an attribute to the method but that didn't work.
You can either put it directly above the static OnPropertyChanged method, in your case right above OnUsersChanged like so:
[SuppressPropertyChangedWarnings]
private void OnUsersChanged(object sender, NotifyCollectionChangedEventArgs e)
or you can put it directly above your class declaration if you have many OnPropertyChanged methods like so:
[SuppressPropertyChangedWarnings]
public class MyClassGrid: Grid
{
...
}
Related
there. I'm new to CEFbrowser.
I'm developing the download model of My CefBrowser.
I've written some code but error while compiling.
class CefClient : public virtual CefBase {
public:
///
// Return the handler for download events. If no handler is returned downloads
// will not be allowed.
///
/*--cef()--*/
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler(){
return this;
}
But VS2015 says C2440:
"return":cannot convert from 'CefClient *const' to 'CefRefPtr<CefDownloadHandler>'
I'm new. and when i change return this to return null it runs, but can't download.
What can i do to solve this problem?
Thank you!
It looks like your CefClient has to inherit from CefDownloadHandler, i.e. class CefClient: public virtual CefBase, public CefDownloadHandler: CEF C++ Implementing download handler
Once you inherit from CefDownloadHandler, returning this from an instance of CefClient will fit correctly as a CefRefPtr<CefDownloadHandler>.
I am using Visual C++ 2010 Express. I have a form (Form1.h) that contains a text box (textBox1).
I want another test.cpp to be able to access to textBox1 and display the message.
I have something like:
in Form1.h
... standard form code generated by Visual Studio
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Text = "Connecting to server ...";
}
And in test.cpp contains something like
....
void write (const unsigned char *data, int length)
{
System::Windows::Forms::textBox1->Text = "Send failed";
}
....
After compiling, I have got the following errors:
'textBox1' : is not a member of 'System::Windows::Forms'
'textBox1' : undeclared identifier
left of '->Text' must point to class/struct/union/generic type
syntax error : missing ';' before 'string'
I am new to Visual C++ and don't know how to access class/object properly.
Thanks in advance for your help.
I think some of the compiler issues can be resolved by changing:
System::Windows::Forms::textBox1 to just textBox1
Another way of thinking is textBox1 is a managed (^) pointer of type System::Windows::Forms::TextBox.
Other typos may still be present. The snippets above appear to be in C++/.NET. This is a different beast from 'regular' C++.
I have created a Windows Form Project in VC++ 2010 Express version. So, in that project I created a Form, which had only 1 button and 1 textbox. The name of this form was Form1.
This button called a function FD written in a .cpp file in the same project. However, while running the code, I need to update the textbox with some text. I want to access the textbox through the .cpp file.
I have tried the following:
I included #include "Form1.h" and then wrote textBox1->Text="XYZ". However, while building it says that it cannot find any member called textBox1.
How do I access the textbox from the .cpp file?
EDIT:
FD.cpp
#include<stdafx.h>
#include "Form1.h"
... //other includes
void abc()
{
//Some code
textBox1->Text="String to be displayed."
//Some code
}
Form1.h
This is simple GUI form, where a button called button1 and a textbox called textBox1 is added.
#include<FD.h>
//code generated by the GUI
void button1_click()
{
abc();
}
// FD.cpp
void abc(Form1^ f)
{
// Assuming that textBox1 is public. If not, make it public or make
// public get property
f->textBox1->Text="String to be displayed."
//Some code
}
// Form1.h
void button1_click()
{
abc(this);
}
Or:
// FD.cpp
void abc(TextBox^ t)
{
t->Text="String to be displayed."
//Some code
}
// Form1.h
void button1_click()
{
abc(textBox1);
}
Another way: make abc method return type String^ and set its return value in Form1 to textBox1. Advantage: abc doesn't know anything about UI level. Yet another way: events http://msdn.microsoft.com/en-us/library/58cwt3zh.aspx
The reason you're getting this error is because you haven't specified whose textBox that is. It is not enough to #include the header file, you need to find a way to communicate with your Form1 object. You can do this in several ways.
Using a global pointer to the instance of your main Form1 that can be accessed from anywhere,
Using a local pointer to the instance of your main Form1 that is passed around and can be called upon,
Providing a friend function that can manipulate the data in the class (not recommended),
I would choose 2.
Can anyone help me solve this?
error C2380: type(s) preceding 'Form1' (constructor wit`h return type, or illegal redefinition of current class-name?)`
I try to make a program using windows form in Visual c++ 2008. But I got that error above.
below is my header file code part >> form1.h:
#pragma endregion
private: System::Void Form1(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
Actually i have browsed about this error, but stil because my stupidity I still cant figure it out..
Constructors should not be declared as returning anything. You just need to omit System::Void:
private: Form1(System::Object^ sender, System::EventArgs^ e) {
// implement your constructor here
}
I am writing unit test case for my internal method. I have made necessary changes in AssemblyInfo.cs of my mail class project
[assembly: InternalsVisibleTo("myunitest_assemblyname")]
now i can access my internal method in unit test case method.
but when i compile the code it is giving an error as below
Error 1 'main class project name' does not contain a definition for 'Process' and no extension method 'Process' accepting a first argument of type 'main class project name' could be found (are you missing a using directive or an assembly reference?)
my main class has strong name.
it would be great if some one point where i am missing.
main class structure
namespace Renewals
{
public class StateProcessor
{
internal virtual void PutEmailInQueue(DataTable dataTable)
{
}
}
}
//test class structure
namespace Renewals.Tests.Unit
{
[TestClass]
public class StateProcessorTest
{
[TestMethod]
public void PutEmailInQueueTest()
{
DateTime processingDate = Convert.ToDateTime("27-feb-2013"); ;
StateProcessor stateProcess = new StateProcessor(processingDate);
stateProcess.PutEmailInQueue(new DataTable());
}
}
}
PutEmailInQueue - this method giving me problem.
you wrote that your class use strong name.
I think you have to modify your InternalsVisibleTo() statement with the public key.
e.g.: [assembly: InternalsVisibleTo("friend_signed_B, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e3aedce99b7e10823920206f8e46cd5558b4ec7345bd1a5b201ffe71660625dcb8f9a08687d881c8f65a0dcf042f81475d2e88f3e3e273c8311ee40f952db306c02fbfc5d8bc6ee1e924e6ec8fe8c01932e0648a0d3e5695134af3bb7fab370d3012d083fa6b83179dd3d031053f72fc1f7da8459140b0af5afc4d2804deccb6")]
for more informations see: http://msdn.microsoft.com/en-us/library/bb385180.aspx