I've created C++ DLL project, this dll contains mostly native c++ code, but it have 1 mixed class written in C++ and using some .NET types.
This class is declared in header file and have implementation in .cpp
I can use it from all *.cpp files, but when i try to declare reference to C++/CLI class in some c++ header file i got tons of errors about project doesnt support CLR(CLR support in project settings as /clr is set up), it looks like header files doesnt support links to managed classes.
This works from .CPP perfectly but fails with errors when used from .H
#include "NativeBitmap.h"
using namespace Native;
NativeBitmap.H:
#pragma once
namespace Native
{
using namespace System;
using namespace System::Drawing;
using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices;
public ref class NativeBitmap
{
}
}
NativeBitmap.CPP:
#include "stdafx.h"
#include "NativeBitmap.h"
using Native::NativeBitmap;
using namespace System;
using namespace System::Drawing;
using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices;
void NativeBitmap::Create(...)
{
...
}
and so on ...
Related
I have created a static library(c++/WinRT) and an Universal Windows App [Blank App] (c++/WinRT)project in VS 2019.
Then From Project Universal Window app I added project reference of the static library.
I am getting below error while building the universal app
D:\Dv\Main\Vib\CM\UI\UserInterfaceCppWinRT\Generated Files\XamlTypeInfo.g.cpp(178,52): error C2039: 'UIViewModelCppWinRT': is not a member of 'winrt'
Individually the static library build successfully. Not getting any clue about c++/winrt static library project consumption. Any suggestion?
When you add reference of the static library to main project and build main project successfully, you can find it has generated the StaticLibrary.h file under the \MyProject\MyProject\Generated Files\winrt folder along with other Windows namespaces. So if you want to import the idl(e.g. Class.idl), you don't need to import it manually, since your toolchain is set up to automatically reference any types that are in system namespaces. You only need to import any types that you've defined in your project. For example:
MainPage.idl
namespace WinrtApp
{
[default_interface]
runtimeclass MainPage : Windows.UI.Xaml.Controls.Page
{
MainPage();
Int32 MyProperty;
StaticLibrary1.Class MyClass;
}
}
When you want to access the property from static library, first include the header file and initialize it.
MainPage.h
private:
StaticLibrary1::Class myclass{nullptr};
.cpp:
#include "winrt/StaticLibrary1.h"
myclass = StaticLibrary1::Class();
int property = myclass.MyProperty();
Here is a simple sample that I created, you can download it to check the complete steps.
I am new to YII framework. My whole code is correct but undefined namespace error is present. Please set the error.
model
<?php
namespace app\models;
use yii\base\Model;
view
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
controller
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;
use app\models\UserForm;
error
Undefined namespace filters
Undefined namespace web
Undefined namespace models
I guess you are using advanced applocation of Yii2. If so, it is better to use namespace frontend\models; or namespace backend\models; relative where those file is located
I am setting up a multi-module application, so far I have it setup like this example http://docs.phalconphp.com/en/latest/reference/applications.html.
But I was wandering if its possible to have shared base controller that both the backend and frontend controllers extend from. This is so I can have a single ACL in the base controller. How would I set that up?
According to the docs I can create a controllerbase anywhere and then just require this file directly in the bootstrap file or cause to be loaded using any autoloader. So I created a folder called apps/shared/controllers/ControllerBase.php and required this file directly in the bootstrap file but this does not work.
If I try to load a controller like so:
class AdminController extends ControllerBase
{
public function indexAction()
{
echo "<h1>Hello admin!</h1>";
}
}
I get an error ...Backend\Controllers\ControllerBase' not found in......
So how do I cause to be loaded using any autoloader as per the docs? Do I need to register it as its own namespace or something?
You not using the full namespace path for your base controller so the autoloader attempts to find it under in the same namespace of the child class.
Try something like this:
namespace MyApp\Backend\Controllers;
use MyApp\Shared\Controllers\ControllerBase;
class AdminController extends ControllerBase
{
public function indexAction()
{
echo "<h1>Hello admin!</h1>";
}
}
This answer consider that you have applied the PSR-0 and PSR-4 properly.
I have an Adobe AIR ANE that builds and runs fine on iOS. I want to run this app in the AIR simulator, but with an actionscript version of the native ANE.
Reading the docs, it seems like a default profile would be perfect for this.
I added the default profile to the extension.xml file. I added a AS implementation of the native interface to every project in my workspace. I have made methods static/not static, etc. I have tried everything but I keep getting this error:
ArgumentError: Error #3500: The extension context does not have a method with the name
I am at a complete loss. Here are the relevant files:
extension.xml
<extension xmlns="http://ns.adobe.com/air/extension/3.1">
<id>com.novel.analytics.ext.ApsalarNativeInterface</id>
<versionNumber>0.0.0</versionNumber>
<platforms>
<platform name="iPhone-ARM">
<applicationDeployment>
<nativeLibrary>libApsalarNativeInterface.a</nativeLibrary>
<initializer>ExtInitializer</initializer>
<finalizer>ExtFinalizer</finalizer>
</applicationDeployment>
</platform>
<platform name="default">
<applicationDeployment/>
</platform>
</platforms>
</extension>
My AS implementation:
package com.novel.analytics.ext
{
public class ApsalarNativeInterface
{
public function ApsalarNativeInterface()
{
}
private static function initExtension():void
{
}
public function initApsalar(apiKey:String, secret:String):void
{
}
}
}
my native interface:
package com.novel.analytics
{
import flash.external.ExtensionContext;
public class ApsalarInterface
{
private static const EXTENSION_ID : String = "com.novel.analytics.ext.ApsalarNativeInterface";
private var context : ExtensionContext;
public function ApsalarInterface()
{
this.context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
}
public function initApsalar(apiKey:String, secret:String):void
{
context.call("initApsalar", apiKey, secret);
}
}
}
Here is my adt command line (library.swf is the lib that contains the two above files:
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package -target ane ../../$PRODUCT_NAME.ane extension.xml -swc NativeInterface.swc -platform iPhone-ARM -C . library.swf -platform default -C . library.swf
Like I said, I am at a complete loss on this one.
Sorry for the much delayed response, but I think you'd benefit from checking out this wonderful tutorial:
http://www.digitalprimates.net/author/nweber/2012/04/10/building-a-native-extension-part-3/
Based on your code snippets above, it looks like you're trying to define your pure-ActionScript implementation in a different package, with a different classname. Seems you actually want to use the same package+class+method names and just store it in a different library (so it's bundled as its own SWF). Then you tell ADT how to bundle things.
i have the following class in eclipse
class AddEntryAction extends Action {
public AddEntryAction() {
super("Add Entry");
setToolTipText("Add Entry");
}
public void run() {
WizardDialog dlg = new WizardDialog(MainClass.mainWindow.getShell(),
new AddEntryWizard());
dlg.open();
}
}
and Action class extends AbstractAction which intern extends EventManager class. Both these parent classes are part of the eclipse SWT/jface libraries... I get the following error on the above class declaration
The project was not built since its
build path is incomplete. Cannot find
the class file for
org.eclipse.core.commands.common.EventManager.
Fix the build path then try building
this
project DisplayExample Unknown Java
Problem
The type
org.eclipse.core.commands.common.EventManager
cannot be resolved. It is indirectly
referenced from required .class
files MainClass.java /DisplayExample/src line
94 Java Problem
AddEntryAction is declared within the same source file MainClass.java. Actually, this is an example from Java2s.com ... I have the libraries/jars because i can see the compiles classes of all these clases
The error "The project was not built since ... org.eclipse.core.commands.common.EventManager cannot be resolved..." with swt/jface dependencies can be caused by missing reference sources or binaries containing org.eclipse.core packages in addition to org.eclipse.swt and org.eclipse.jface packages.
E.g. build path in my case included:
swt.jar
org.eclipse.jface_3.4.2.M20090107-0800.jar
Following jar was missing and caused above error:
org.eclipse.core.commands_3.4.0.I20080509-2000.jar