我在VS 2005中编译我的C++项目解决方案时遇到链接错误.以下是该场景.
我有一个解决方案,让我们说MySolution有2个项目名称
MyTestLib是一个静态库类型的项目,具有字符集Use Multi-Byte Character Set,没有CLR支持
和
MyTestApp是一个.exe应用程序使用上面的lib与字符集Use Unicode Character Set和CLR支持
在MyTestLib没有与下面的定义两个重载函数
int Class1::test1(int a)
{
return a+4;
}
bool Class1::test1(LPCTSTR param)
{
return true;
}
Run Code Online (Sandbox Code Playgroud)
MyTestApp 从它的代码中调用它们
Class1 objcl1;
int a = objcl1.test1(12); //Works fine
Class1 objcl2;
string abc = "adsad";
bool t = objcl2.test1(abc.c_str()); //Error
Run Code Online (Sandbox Code Playgroud)
调用test1(LPCTSTR)版本会出错
Error 1 error C2664: 'int TestLib::Class1::test1(int)' : cannot convert parameter 1 from 'const char *' …
我正在使用SelectedItem数据绑定的WPF一个奇怪的问题RadListBox,试图找出但没有运气.以下是我的情景
TelerikControls(RadListBox,和RadButton)RadButton放在一个内部ItemsControl,RadListBox并ItemsControl绑定到同一个ItemsSource.PRISM和MVVM.RadListBox自动选择相同的项目,(这部分工作正常).RadListBox然后单击任何按钮,项目选择就会停止工作.RadListBox?现在让我来编码.
ViewModel类
public class MainViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
} …Run Code Online (Sandbox Code Playgroud) 我想在WPF中使用运行基本数据验证示例ValidatesOnException,但它根本不起作用,并且一旦我viewmodel抛出ValidationException,我的程序崩溃说,ValidationException未被用户代码处理.
我的视图模型是
public class MainViewModel : INotifyPropertyChanged
{
//INotifyPropertyChaned implementation
//////////////////////////////////////
private string stringValue;
public string StringValue
{
get { return stringValue; }
set
{
if (value.Length > 6)
{
//The below line throws unhandled exception error??
throw new ValidationException(String.Format("Value's length is greater than {0}.", value.Length));
}
stringValue = value;
this.OnPropertyChanged("StringValue");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的XAML是
<StackPanel x:Name="LayoutRoot" Background="White">
<TextBox x:Name="radMaskedTextInput1"
Width="200"
Margin="10"
Text="{Binding Path=StringValue, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud) 我在C++中尝试一个简单的代码,但是Debug Assertion Failed _BLOCK_TYPE_IS_VALID当我删除指针时出现错误.我不知道我错了什么.这是我的代码.
hash_map<string,string> m_hashDetails;
m_hashDetails.insert(hash_map<string,string>::value_type("test",*(new string("test123"))));
hash_map<string,string>::iterator myIterator;
myIterator = m_hashDetails.find("test");
if(myIterator == m_hashDetails.end())
{
printf("not found");
}
else
{
printf(myIterator->second.c_str());
//this is where I get Debug Assertion Failed _BLOCK_TYPE_IS_VALID
delete &(myIterator->second);
}
Run Code Online (Sandbox Code Playgroud)
当我删除我得到错误的second字段.我错了什么?我用运营商分配了这个字段?有一件事我注意到,如果我将hash_map定义更改为
并插入类似的值hash_mapDebug Assertion Failed _BLOCK_TYPE_IS_VALIDsecondnewhash_map<string,string *> m_hashDetails;
m_hashDetails.insert(hash_map<string,string>::value_type("test",new string("test123")));
Run Code Online (Sandbox Code Playgroud)
然后delete不给出错误..并且工作正常?这个错误的实际原因是什么?
c++ ×2
data-binding ×2
wpf ×2
assertions ×1
exception ×1
exe ×1
mvvm ×1
new-operator ×1
prism ×1
telerik ×1
validation ×1