且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在c ++ / cli类中使用c#custom属性

更新时间:2023-02-21 08:20:59

您好Chandrakant2411,


感谢您发布此处。


对于您的问题,您在下面使用的库是什么。根据我的搜索,我找不到它。难道 你提供了更多的信息吗?

使用名称空间Sample :: Generic :: TestAutomation :: TestSystem; 
使用名称空间Sample :: CheckIt :: GeneralIO;
使用名称空间Sample :: CheckIt :: Foundation :: GenericLogger;

***的问候,


Wendy


I want to use C# custom attribute for C++/CLI class or method. 

Please find the below code which i have written in c++/cli and class inherited from c# class. 

using namespace std;
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Reflection;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
using namespace Sample::Generic::TestAutomation::TestSystem;
using namespace Sample::CheckIt::GeneralIO;
using namespace Sample::CheckIt::Foundation::GenericLogger;

namespace ClassLibrary1 {
[TestCase]
public ref class Class1 : public Sample::CheckIt::TestPool::TestCase
{
private:
static Class1^ Instance = nullptr;
GenericLogger^ Switchmodule_log;
TAIoPortClient^ _generalio;
bool _testCaseInit = false;

};

[TestCase] attribute coming from Sample::Generic::TestAutomation::TestSystem namespace. my code is building properly when i loaded my created dll into my testapp application, i am this getting "Could not load TestCases from the ClassLibrary1!Assembly has no TestCases defined" . as per my understanding the application is not able to read the TestCase attribute. Please suggest how to rectify these issue. 

Hi Chandrakant2411,

Thank you for posting here.

For your question, what is the library you used below. Based on my search, I do not find it. Could  you provide more information of it?

using namespace Sample::Generic::TestAutomation::TestSystem;
using namespace Sample::CheckIt::GeneralIO;
using namespace Sample::CheckIt::Foundation::GenericLogger;

Best Regards,

Wendy