Could not be found - c#-4.0

When I use the EntityFramework.Extended in my RiceBuySellProvider project, I got this error in my main project:
The type or namespace name I remove the 'RiceBuySellProvider' could not be found (are you missing a using directive or an assembly reference?)
From MainProject Image
But when I remove the .FutureFirstOrDefault() of EntityFramework.Extended from my RiceBuySellProvider and no errors found. Why?
UPDATE
When I use the .FutureFirstOrDefault() this will be the cause of the error.
public static ProductEntity GetProduct(string productNo)
{
using (var con = new RiceBuySellEntities(ConnectionStr))
return CompiledQueries.GetProCatTypeUnit.Invoke(con, productNo).FutureFirstOrDefault();
}

You need to add a reference to the assembly that holds the namespace you are importing.
Project Properties > Refernces
Edit
Its possible that the Rice assembly targets an incompatible framework, or that its bittyness (x86 / x64) is mismatched.

Related

Updating to new ubuntu server breaks g++ build with a bunch of c++/9 errors?

We are moving to a new Ubuntu server (newer Ubuntu version) and the old build is not working. We get tons of errors from c++/9. A couple examples below. Any idea how I get the build (a single .cpp file) to work using g++?
/usr/include/c++/9/array: In function 'bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)':
/usr/include/c++/9/array:264:19: error: 'lexicographical_compare' is not a member of 'std'; did you mean 'lexicographical_compare'?
264 | return std::lexicographical_compare(__a.begin(), __a.end(),
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/memory:62,
from /usr/include/unicode/localpointer.h:45,
from /usr/include/unicode/uenum.h:23,
from /usr/include/unicode/ucnv.h:53,
from /usr/include/libxml2/libxml/encoding.h:31,
from /usr/include/libxml2/libxml/parser.h:810,
from /usr/include/libxml2/libxml/xmlerror.h:10,
from /usr/include/libxml2/libxml/xpath.h:26,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-xml.h:27,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-env.h:29,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-client.h:27,
from myapp.cpp:6318:
/usr/include/c++/9/bits/stl_algobase.h:1277:5: note: 'lexicographical_compare' declared here
1277 | lexicographical_compare(_II1 __first1, _II1 __last1,
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/array: In member function 'void std::array<_Tp, _Nm>::fill(const value_type&)':
/usr/include/c++/9/array:117:14: error: 'fill_n' is not a member of 'std'; did you mean 'fill_n'?
117 | { std::fill_n(begin(), size(), __u); }
| ^~~~~~
In file included from /usr/include/c++/9/memory:62,
from /usr/include/unicode/localpointer.h:45,
from /usr/include/unicode/uenum.h:23,
from /usr/include/unicode/ucnv.h:53,
from /usr/include/libxml2/libxml/encoding.h:31,
from /usr/include/libxml2/libxml/parser.h:810,
from /usr/include/libxml2/libxml/xmlerror.h:10,
from /usr/include/libxml2/libxml/xpath.h:26,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-xml.h:27,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-env.h:29,
from /usr/local/include/libcsoap-1.1/libcsoap/soap-client.h:27,
from myapp.cpp:6318:
I setup a test.cpp and included the same headers as myapp.cpp and it worked. Weird, so I then tried a few #define items included in myapp.cpp and tried again, worked. Now in myapp.cpp the include files for the soap-client.h was down in the middle of the code for CGI support. I moved the #include for that up to the top with the other #include items and it compiled fine.
My only thought is there must have been something in the code, either a function, typedef or #define that conflicted with some of the standard headers?
Anyway, if you run in to something like that, here is one thing to check.

Error using Box SDK on Azure Functions

I am getting a "Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified" error in Azure Functions. Any ideas on what the problem might be?
I am using the package.json file to have Azure Functions pull in the references and hook them all up as described in the docs.
When you upload a project.json file, the runtime gets the packages and automatically adds references to the package assemblies. You don't need to add #r "AssemblyName" directives. Just add the required using statements to your run.csx file to use the types defined in the NuGet packages.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp
My package.json file:
{
"frameworks": {
"net46":{
"dependencies": {
"BouncyCastle": "1.8.1",
"BouncyCastle-PCL": "1.0.0.6",
"Box.V2": "2.14.0",
"Box.V2.JWTAuth": "1.2.0",
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168",
"Microsoft.Bcl.Build": "1.0.14",
"Microsoft.Net.Http": "2.2.29",
"Newtonsoft.Json": "6.0.2",
"Nito.AsyncEx": "2.1.3",
"System.IdentityModel.Tokens.Jwt": "4.0.2.206221351"
}
}
}
}
run.csx using statements:
using global::Box.V2;
using global::Box.V2.Config;
using global::Box.V2.Exceptions;
using global::Box.V2.JWTAuth;
using global::Box.V2.Models;
Full Exception:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.GetTelogisFormInstancePdf ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
at Submission#0.Run(HttpRequestMessage req,TraceWriter log) at : 84
End of inner exception
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture)
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)
at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??…
The error is clearly stating that it can't find the assembly:
System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
And while you show in your .csx that you have using statements to include the namespaces, no where do you show that you actually reference the external assemblies
As described in the above linked documentation:
If you need to reference a private assembly, you can upload the assembly file into a bin folder relative to your function and reference it by using the file name (e.g. #r "MyAssembly.dll").
Make sure you get the path correct; I had to ensure the bin folder was within my path where the function was - the shared assembly approach didn't work for me.
I also suggest that perhaps an easier approach than dealing with csx and referencing assemblies is to ditch csx all together and use pre compiled functions as described in this blog post. Then you get full compile time resolution of assemblies and proper intellisense that you just don't get with the CSX files.
This error is misleading and I had to end up overriding BoxJWTAuth in order to make it work. The details of this error can be found here: https://github.com/box/box-windows-sdk-v2/issues/297

Kentico 7 error Type or Namespace WorkflowManager could not be found

I am trying to setup a Kentico 7 patch 58 site. I downloaded Kentico installation manager 7 and created a new site. When I access the site I get the error
Compiler Error Message: CS0246: The type or namespace name 'WorkflowManager' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 16: protected TreeProvider mTreeProvider = null;
Line 17: protected WorkflowStepInfo mWorkflowStepInfo = null;
Line 18: protected WorkflowManager mWorkflowManager = null;
Please advise what I could be missing here.
You are probably using web application project type and you didn't rebuild the project after applying the HF.
Please refer to: C:\Program Files (x86)\KenticoCMS\7.0\Hotfix70_58\Instructions.pdf (page 7)
Also look at the page 12 (Additional notes and workarounds) and check whether there are any manual steps you have to take.

Unable to load so file from Java in Eclipse On Ubuntu

I have some code that tries to load a C library as follows :-
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
However I get the following error when trying to build the project; The error I get is as follows :-
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at com.threads.ThreadAffinity.<init>(ThreadAffinity.java:11)
at com.threads.ThreadAffinity.main(ThreadAffinity.java:45)
The current working directory is the root of the project and thats where the so file is located. I also tried modifying the LD_PRELOAD variable to point to my so file; however the error persists.
It works just fine on my OSX where the dylib is located exactly where the so file is currently(project root).
What am I doing wrong?
From the exception:
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
It implies you used something like:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("libctest", CTest.class);
}
and not:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
hence you see the JNA added prefix of lib and postfix of .so added to libctest (liblibctest.so)
LD_PRELOAD is used when you want to prefer one particular version of the same shared library over another, which doesn't apply here.
Define jna.library.path to point to your project root, and JNA should be able to find it.
Also make sure your library has been built as libctest.so and wasn't inadvertently named libctest.dylib.

Which is the environment variable for Mono/C# library DLLs?

I'm running the frozen Debian 7.0 Testing/Wheezy.
Here is my C# sample code:
using System.Windows.Forms;
using System.Drawing;
public class Simple : Form
{
public Simple()
{
Text = "Simple";
Size = new Size(250, 200);
CenterToScreen();
}
static public void Main()
{
Application.Run(new Simple());
}
}
I got the above C# WinForms code sample working in Monodevelop by using the System.Drawing and System.Windows.Forms references as well as in the command line when compiling with the following command:
mcs /tmp/Simple.cs -r:/usr/lib/mono/4.0/System.Windows.Forms.dll \
-r:/usr/lib/mono/4.0/System.Drawing.dll
I'm trying to make the mcs command work without needing to use the -r switch/parameter (which, by the way, I cannot find information on by looking through man mcs - I basically found this switch/parameter on some random website and it worked).
To check if it worked temporarily, I issued
export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
prior to issuing mcs /tmp/Simple.cs, which failed with the errors within the following output:
deniz#debian:~$ cd /tmp
deniz#debian:/tmp$ export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
deniz#debian:/tmp$ mcs Simple.cs
Simple.cs(1,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Simple.cs(2,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 2 error(s), 0 warnings
deniz#debian:/tmp$
The above output tells me that the mcs compiler/utility is not seeing the dll files but I don't know what else to try.
Any help in getting the WinForms and Drawing libraries to be automatically “looked at” would be greatly appreciated!
I'm trying to make the mcs command work without needing to use the -r switch/parameter
This is not possible, mcs will not look for libraries unless you tell it to look for them (which is done with -r:...).

Resources