I am working on a project with Windows Forms in Visual C++ 2010. I am using the BasicExcel class. Here is the relevant code:
I include the header file:
#include "BasicExcel.hpp"
using namespace YExcel;
Then I have the software write "Test str1" at the cell 1,4 when I push a button:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
//Code for Writing to Excel
BasicExcel x;
// Load a workbook with one sheet, write some test data at (1,4)
x.Load("TestFile.xlsx");
BasicExcelWorksheet* sheet = x.GetWorksheet("Sheet1");
BasicExcelCell* cell;
sheet->Cell(1,4)->SetString("Test str1");
}
When I do this I get the following errors:
1>Enter Loads.obj : error LNK2028: unresolved token (0A000020) "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell#BasicExcelWorksheet#YExcel##$$FQAMPAVBasicExcelCell#2#II#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005A) "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell#BasicExcelWorksheet#YExcel##$$FQAMPAVBasicExcelCell#2#II#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000021) "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString#BasicExcelCell#YExcel##$$FQAMXPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005B) "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString#BasicExcelCell#YExcel##$$FQAMXPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000022) "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet#BasicExcel#YExcel##$$FQAMPAVBasicExcelWorksheet#2#PBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005C) "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet#BasicExcel#YExcel##$$FQAMPAVBasicExcelWorksheet#2#PBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000023) "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load#BasicExcel#YExcel##$$FQAM_NPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005D) "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load#BasicExcel#YExcel##$$FQAM_NPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000024) "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005E) "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000025) "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005F) "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel#YExcel##$$FQAM#XZ)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString#BasicExcelCell#YExcel##$$FQAMXPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString#BasicExcelCell#YExcel##$$FQAMXPBD#Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell#BasicExcelWorksheet#YExcel##$$FQAMPAVBasicExcelCell#2#II#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell#BasicExcelWorksheet#YExcel##$$FQAMPAVBasicExcelCell#2#II#Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet#BasicExcel#YExcel##$$FQAMPAVBasicExcelWorksheet#2#PBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet#BasicExcel#YExcel##$$FQAMPAVBasicExcelWorksheet#2#PBD#Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load#BasicExcel#YExcel##$$FQAM_NPBD#Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load#BasicExcel#YExcel##$$FQAM_NPBD#Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel#YExcel##$$FQAM#XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#EnterLoads#Agricultural_Software##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel#YExcel##$$FQAM#XZ)
1>C:\Users\Jake\Documents\Agricultural Software\Agricultural_Software\Release\Agricultural_Software.exe : fatal error LNK1120: 18 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have tried to get it fixed but I don't know much about linking. I would appreciate it if someone would enlighten me.
Thanks!
Related
So I know why this error appears in general, but I can't figure out why it appears here.
This is my code:
private void ausfuehrenFunktion(int funktion) {
artikel = new Artikel(einlesenArtikelnummer(), einlesenBezeichnung(), einlesenBestand(), einlesenPreis());
Lager.legeAnArtikel(artikel);
}
public void legeAnArtikel(Artikel artikel){
lager[stelle] = artikel;
stelle++;
}
I'm trying to create my own RouteBuilder but I'm getting the following error:
java.lang.IllegalArgumentException: onException must be defined before any routes in the RouteBuilder
at org.apache.camel.builder.RouteBuilder.onException(RouteBuilder.java:214)
at com.mdw360.ttt.mongo.fab.route.ExceptionBuilder.configure(ExceptionBuilder.java:18)
at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:679)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:302)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
On my ExceptionBuilder I have this code:
public class ExceptionBuilder extends RouteBuilder{
#Override
public void configure() throws Exception {
ExceptionProcessor exceptionProcessor = new ExceptionProcessor();
onException(Exception.class).process(exceptionProcessor);
}
}
And on my test I have that:
#Test
public void testExceptionWhileRouting() throws Exception {
getMockEndpoint("mock:http").expectedBodiesReceived("Camel rocks");
getMockEndpoint("mock:http").whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("ERROR");
exchange.setException(new ConnectException("Simulated connection error"));
}
});
template.sendBody("direct:file", "Camel rocks");
assertMockEndpointsSatisfied();
}
#Override
protected RouteBuilder createRouteBuilder() {
ExceptionBuilder routeBuilder = new ExceptionBuilder();
routeBuilder.from("direct:file").to("mock:http");
return routeBuilder;
}
As I'm adding the onException into the configure, why it's saying that I must define it before any route?
You need to move this:
from("direct:file").to("mock:http");
to the configure() method, after you call onException(). So it looks like this:
public class ExceptionBuilder extends RouteBuilder{
#Override
public void configure() throws Exception {
onException(Exception.class).process(new ExceptionProcessor());
from("direct:file").to("mock:http");
}
}
Then your createRouteBuilder() method should look like this:
#Override
protected RouteBuilder createRouteBuilder() {
return new ExceptionBuilder();
}
I think the reason it's giving you an error is because routes are expected to contain the from() method call.
You might be able to do something like this if you're trying to create a common exception handling route:
public class ExceptionBuilder extends RouteBuilder{
#Override
public void configure() throws Exception {
from("direct:onException").process(new ExceptionProcessor());
}
}
public class TestRouteBuilder extends RouteBuilder{
#Override
public void configure() throws Exception {
onException(Exception.class).to("direct:onException");
from("direct:start").to("mock:end");
}
}
In my java class i have something like below:
from("direct:dcrm:input")
.routeId("dcrm-route"
.convertBodyTo(Message.class)
.setHeader(
"recipientListHeader",
simple("activemq:"+rdvrQueueName+ ".${body.controllerID}?jmsMessageType=Text&timeToLive="
+ rdvrMessageTimeToLive
+ "&deliveryPersistent=" + deliveryPersistent))
.choice()
.when(simple("${body.messageType} == 'rdvr'"))
.bean(new DcrmMessageHandler(), "process")
.marshal(requestMessage)
.recipientList(header("recipientListHeader"))
.onPrepare(new MesssageProcessor()).parallelProcessing()
.end()
.setBody(constant(StatusCode.SUCCESS))
.otherwise()
.endChoice();
while writing Junit i am doint like this :
#Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "<matched/>";
resultEndpoint.expectedBodiesReceived(expectedBody);
template.sendBodyAndHeader(expectedBody, "recipientListHeader", 0);
resultEndpoint.assertIsSatisfied();
}
#Override
protected RouteBuilder createRouteBuilder() throws Exception {
//return new DcrmOutboundRoute();
return new RouteBuilder() {
#Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("direct:dcrm:input")
.filter(header("recipientListHeader").isEqualTo(constant(StatusCode.SUCCESS)))
.bean(new DcrmMessageHandler(), "process").to("mock:result");
}
};
}
But I am getting the bellow error:
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/NoResultException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Check your classpath or your Maven dependencies, in particular the one referencing JPA (javax.persistence). You should have a dependency with groupId javax.persistence and probably artifactId persistence-api, replace it by org.hibernate.javax.persistence or org.eclipse.persistence dependency.
I have written a simple route, which would get any http request and save it in file:output.
Once saved a processor is created which would read all the requests.
Here is my code:
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.processor.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class LoadBalancer {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("jetty://http://localhost:8080")
.to("file:output");
from("file://output").process(new processor()
{
public void process(Exchange e)
{
System.out.println("Recieved exchange:" + e.getIn());
}
}
);
//.loadBalance().roundRobin().to("http://172.28.39.138:8080","http://172.168.20.118:8080");
}
});
context.start();
Thread.sleep(100000);
context.stop();
}
}
Now when i compile it, i get the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method process(Processor) in the type ProcessorDefinition<RouteDefinition> is not applicable for the arguments (new processor(){})
processor cannot be resolved to a type
On the line `from("file://output").process(new processor()`
I couldn't figure out what kind of error it it.
Am I doing anything wrong in the code?
Any help would be very much appreciated.
Cheers!!
inlined Processors should be written like this...
from("file://output").process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Recieved exchange:" + e.getIn());
}
});
I have a scenario with three entities:
An interface with one method stub
A class that inherits from `System::Windows::Forms::NativeWindow` and implements the interface
A wrapper class that has a private member of the class type and a public property of the interface type. This class also has a `KeyDown` event member that's to be invoked/raised from the window class
These are the files I'm using:
INativeWindow.h
#pragma once
public interface class INativeWindow
{
void Nothing();
};
CLINativeWindow.h
#pragma once
ref class NWHolder;
public ref class CLINativeWindow : System::Windows::Forms::NativeWindow, INativeWindow
{
public:
NWHolder^ Parent;
virtual void Nothing() sealed;
void DoIt();
};
CLINativeWindow.cpp
#include "stdafx.h"
#include "CLINativeWindow.h"
void CLINativeWindow::Nothing()
{
Console::Write("None");
}
void CLINativeWindow::DoIt()
{
Parent->KeyDown(this, nullptr);
};
NWHolder.h
#pragma once
#include "INativeWindow.h"
#include "CLINativeWindow.h"
public ref class NWHolder
{
internal:
event System::Windows::Forms::KeyEventHandler^ KeyDown;
public:
virtual property INativeWindow^ OwnNativeWindow
{
INativeWindow^ __clrcall get() sealed;
void __clrcall set(INativeWindow^ value) sealed;
}
private:
CLINativeWindow^ nativeWindow_;
};
NWHolder.cpp
#include "stdafx.h"
#include "NWHolder.h"
INativeWindow^ NWHolder::OwnNativeWindow::get()
{
return nativeWindow_;
}
void NWHolder::OwnNativeWindow::set(INativeWindow^ value)
{
nativeWindow_ = dynamic_cast<CLINativeWindow^>(value);
}
At compile time, I get this error:
Error 1 error C3767: 'NWHolder::KeyDown::raise': candidate function(s) not accessible ..\NativeWindows\CLINativeWindow.cpp 10
Is there anything that can be done? I tried even #pragma make_public(System::Windows::Forms::KeyEventHandler) but it failed.
The 'raise' inner method of a C++/CLI event is always declared protected. Add a method on NWHolder named "FireKeyDownEvent", and give it whatever accessibility you like.