I have a Windows form application that works fine on Windows 7, but when opened in Windows 10, image files using ResourceManager don't show up. Application is using .Net 3.5 framework. Following is a bit of code:
static readonly System.Resources.ResourceManager rm = new System.Resources.ResourceManager("ImageResources", Assembly.GetExecutingAssembly());
rm.GetObject("ImageName");
Following is the error:
Could not find any resources appropriate for the specified culture or
the neutral culture. Make sure was correctly embedded or linked into
assembly at compile time, or that all the satellite assemblies
required are loadable and fully signed.
System.Resources.MissingManifestResourceException:
Is it due to some kind of incompatibility or Windows 10 is somehow restricting ResourceManager class to use all those images?
Try to check value of Environment.Version (with some MessageBox for example) on the target machine.
If you get 4.0 then you need to change configuration file as was proposed by Dr. Stich.
If you don't have configuration file then create it like described there:
How to: Add an Application Configuration File to a C# Project
And change it content to something like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
Runtime version you can get on supportedRuntime Element page
This issue was eventually resolved by adding CultureInfo.CurrentCulture in rm.GetObject method parameter i.e.
rm.GetObject("ImageName", CultureInfo.CurrentCulture);
Related
Problem: I am working on a program to take the output of tree and re create the directory structure on a different system. My code works for test sets of files that I have created at random. However when dealing with Systems with detailed/long folder names I run into a
System.IO.IOException '(the filename or extension is too long) on this code
String path = #".\" + PreviousDirectory + #"\";
int errorCheck = path.Length;
Directory.SetCurrentDirectory(path, PathFormat.LongFullPath);
Attempted Solutions:
I have found this thread which describes several options. I have tried many of these I am currently not using System.IO I am using AlphaAeonis.Win32.Filesytem which supposedly has support for 32,000 chars in a path however my error occurs on a path that is 282 chars long.
I am also attempting to use .Net Framework 4.6.2 or higher which removed the path limit. I changed my target framework to 4.6.2 in Visual Studio 2017 which I am using I also have .NET SDK 6.0.0 installed. My app.config file which controls how Visual studio runs the code this looks like this
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false"/>
</runtime>
If I change to anything except version = v"4.0" I am asked to install that version of .NET despite having higher version frameworks installed. I assume that the v4.0 is what is actually running.
Questions:
a. How can I ensure that all Directory functions use the Override from the imported Alphaleonis Library?
b. How can I ensure a minimum .Net Version upon Runtime?
c. What else could I set to allow long Paths?
The Solution was switching from .NET Framework to .Net Core.
Thank You to pcalkins
I am trying to load a LabVIEW DLL in a dnxcore application. However the build of LabVIEW is very old, from 2009. So the maximum compatabillity is .NET 3.5. Therefore im using a class library that loads the DLL.
Now comes my exception. C# keeps complaining about not opening an assembly from a network location. Howver I have already set it as trusted but C# still does not trust it, probably has todo something with CAS Policies.
The fix for this issue should be setting the loadFromRemoteSources flag to true. However DNXCore does not default use xml config anymore. So tried it by JSON:
{
"runtime": {
"loadFromRemoteSources": {
"enabled" : true
}
}
}
However this not seem to fix it. I also tried by xml and loading it through the ConfigurationBuilder
// Setup configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddXmlFile("app.config")
.AddEnvironmentVariables();
Configuration = builder.Build();
And the XML:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
So I was curious has anyone already experienced this and knows a fix for this? I know the DLL works since run it from a .NET 3.5 application which does not include the CAS Policy..
I referred the document and it says
Get the client library by using one of the following methods:
Download the zip file from here.
Run the following command in the NuGet package manger console
I installed via NuGet package manger console
var client = new CouchbaseClient();
I didn't get reference for this class CouchbaseClient;
Am i doing wrong or how to rectify this ?
And the code which is working for me is ,
Cluster objCluster = new Cluster();;
IBucket objBucket = objCluster.OpenBucket();
var returnVal = objBucket.GetDocument<dynamic>("strKey").Content;
//For upserting
objBucket.Upsert(strkey, objDoc);
This is working for me.
Problem in this is :
All the inserts are falling into default bucket.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="couchbase">
<section name="bucket-1" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</sectionGroup>
</configSections>
<couchbase>
<bucket-1>
<servers bucket="default">
<add uri="http://10.0.0.1:8091/pools/default"/>
</servers>
</bucket-1>
</couchbase>
</configuration>
In that bucket="default" i changed default to other bucket. Still couldn't succeeded.
Please clarify me in two things:
What dll i need to use
And in the configuration what exactly i need to change ?
UPDATE :
If i removed the dll added via nuget and added via the one present in zip that class is coming.
But Still didn't succeeded in the config part and also why the change in nuget and the package.
Which one to follow ? The document is explained with dlls in zip.
NuGet and dll
CouchbaseClient is from older versions of the SDK (< 2.0). Latest NuGet package is indeed version 2+.
The snippet of code you provided is ok using SDK 2.0.
Where is the documentation you referred to? Where did you download the zip?
Client configuration and connecting to a non-default bucket
I'm not entirely sure about the client configuration's schema, but I don't think what you did does anything. OpenBucket() always opens the "default" bucket (hardcoded), and you should use OpenBucket(BucketName, BucketPassword) to open a different one.
Also, for the cluster to take your App.config into account at all, it must be created using the constructor that takes the config section as a parameter: new Cluster("couchbase/bucket-1");. This is usually useful for bootstrapping configuration ( tags) and choosing different ports / activating SSL, since the default constructor will only try to connect on localhost.
See the test configuration for examples.
"FileLoadException was unhandled by user code"
(Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information)
as the matter above.i got exception when try to execute
Axapta axapta;
AxaptaRecord axaptaRecord;
List<Vendor> vendors = new List<Vendor>();
public void Submit(Vendor vendor)
{
axapta = new Axapta();
axapta.Logon(null,null, null, null);
using (axaptaRecord = axapta.CreateAxaptaRecord("IDS_Pelajar"))
{
axaptaRecord.Clear();
axaptaRecord.InitValue();
axaptaRecord.set_Field("TenteraPolisNo", vendor.VendorAccount);
axaptaRecord.set_Field("Poskod", vendor.InvoiceAccount);
axaptaRecord.set_Field("Keturunan", vendor.Name);
axaptaRecord.Insert();
}
axapta.Logoff();
vendors.Add(vendor);
i already try to add this line of code in app.config
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
but still it doesn't work.
i have no problem to execute that block of code in console..the exception only pop up when i'm try to execute that block of code in WCF services library
sorry for trouble but i really loss now..Tq 4 help
Check if any of the below help you
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information - Release Build
Handling Mixed Mode Assembly Error in WCF Service Host
Being WCF, I feel the 2nd link might prove useful. The config file for WCF Service host is located at C:\Program Files (x86)Microsoft Visual Studio 10.0Common7IDEWcfSvcHost.exe.config and hence making the change in this config file should fix it.
Hope this helps.
These days I'm very much busy on developing an activex/com application. Some of our customers are working under heavily restricted windows environments. So i decided to make my application regfree. I found genman32.exe which can easily create manifests (also mt.exe is useful). Everything went fine but when i tried to execute my application from wsh(vbs or js) -which is obligated for my the situation because the application works on a com server-
set o = CreateObject("Application.Interface")
// No object reference
Because "CreateObject" looks to the registery and there is no registery entry :) then i searched and found the thing that is "actctx". It is very easy to implement in a dot.net environment. But i must execute my application from wsh(vbs or js) ;) so i decided to search a little then found
set o = CreateObject("Microsoft.Windows.ActCtx")
o.manifest = "L:\\Application.dll.manifest"
set app = o.CreateObject("Application.Interface")
app.Launch() // which is my executing function
Problem -
"Microsoft.Windows.ActCtx" interface is not available in Windows Xp machines even in SP3 - Microsoft never lets it easy -
Is there any solution to that problem? Do You know any other methods or windows update that creates that interface?
I figured out the problem with my manifest. I'll share it with anyone else who may have run into a similiar problem.
Please be aware that you MUST specify the progid="" property in your manifest when using this with the "Microsoft.Windows.ActCtx" interface otherwise you get ActiveX Component Can't Create Object error.
<comClass
clsid="{ED59F192-EF2E-4BCC-95EB-85A8C5C65326}"
progid="myclass.process"
threadingModel = "Apartment" />
The following manifest example should get you up and running :)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="myclass"
version="1.0.0.0"/>
<file name = "myclass.dll">
<comClass
clsid="{ED59F192-EF2E-4BCC-95EB-85A8C5C65326}"
progid="myclass.process"
threadingModel = "Apartment" />
<typelib tlbid="{7AE20C3A-48C2-42C1-A68D-A1C3EB0A2C65}"
version="1.0" helpdir=""/>
</file>
<comInterfaceExternalProxyStub
name="_PROCESS"
iid="{187D0811-470D-44C0-B68C-C1C7F3EEFDA0}"
proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
baseInterface="{00000000-0000-0000-C000-000000000046}"
tlbid = "{7AE20C3A-48C2-42C1-A68D-A1C3EB0A2C65}" />
</assembly>
If the Microsoft.Windows.ActCtx were redistributable, there would have to be some way for it to get onto the machine and globally registered. If you had access to register this on the machine, can't you insted simply register Application.Interface? If you're dealing with a restricted environment ... well you have to deal with what's available already.
It looks like you're using the wsh script to launch your application. Why not write a stub to launch the app in native or managed code (where you will be able to use a manifest), and call that stub instead?