I've got a silverlight application that loads a dll file located within the ClientBin folder at run time via a relative Uri. It works great on my local machine, but when deployed on a server here, it seems to constantly fail while trying to load the file:
private void OnAssemblyOpened(object sender, OpenReadCompletedEventArgs e)
{
AssemblyPart asmbPart = new AssemblyPart();
MessageBox.Show(e.ToString());
Assembly asmb = asmbPart.Load(e.Result) // this line causes the exception
...
}
Of course silverlight doesn't give me a useful error - just the usual NotFound nonsense. Is there a step I've missed in deploying this? Permissions or something? The dll file is definitely in the ClientBin folder btw - I've checked that! :)
Another option would be to compress the dll into a zip file, then download the zip file. That way you need not play with the server config.
How to download and unpack a file from a Zip file is given in this answer.
Code in essence would look like this:-
AssemblyPart asmbPart = new AssemblyPart();
var zipRes = new StreamResourceInfo(args.Result, null)
var assemRes = Application.GetResourceStream(zipRes, new Uri("YourAssembly.dll", UriKind.Relative));
Assembly asmb = asmbPart.Load(assemRes.Stream)
Try to use absolute path for deployed application and give your url + path-to-clietbin as path.
You may got error because of invalid path on server machine(if you didn't change it and it's still path of your local machine).
Problem was that I'm running IIS6 and dll's cannot be served out without switching execute permissions on the site to None (which obviously stops the Silverlight app from running) so I was legitimately getting a 404 - who'd have thought!!
I created a virtual directory for my scripts at the top level of my site and stuck the dll in there, switched the execute permissions for the virtual to None, updated the uri to ../scripts/ControlLibraries.dll and job's a goodun!
Actually, just change the execute permissions on your application to Scripts only, instead of Scripts and Executables, should work fine.
Related
I'm working with selenium. The script is in :
C:\Users\User\Desktop\Data Analytics Arg\Proyectos\datademia\Py_install\py_ejemplo.py . Venv is activated and chromedriver.exe is in C:\Users\User\Desktop\Data Analytics Arg\Proyectos\datademia\Py_install\chromedriver.exe
The script runs perfectly. Then I created an only .exe-file via terminal :
pyinstaller --add-data "chromedriver.exe;." --windowed --onefile py_ejemplo.py
Folders are created correctly (build and dist). The .exe file (py_ejemplo.exe) was created, but when I try to run it, I get this message:
I've been looking and still can't solve it... I've tried these solutions :
filenotfound
but didn't work for me...Could someone help me? I don´t know what's wrong...
Thanks in advance
I got the same problem but I was working with Firefox and geckodriver.
In my case, I copied the selenium folder from the virtual environment to the dist folder and it worked.
There are a few things you should ensure when packing a script with pyinstaller build with selenium web driver.
It may require to add driver executable when building. I.e. chromedriver.exe
It may also require to add some package files related to selenium such as getattributes.js file when building. It was required at my project.
pyinstaller will extract those files to temp folder in AppData for windows users. So in your code, your relative paths may require to be resolved with a sample function as below (if you are running your code in vs code or you are running through pyinstaller executable the paths should be resolved by function).
For item 1 and 2, you can use --add-binary and --add-data features of pyinstaller for each of them. It is also possible to do this in *.spec file with add-files list, following your first running of pyinstaller (see this explanation) I preferred command-line option as below.
pyinstaller ./app.py --onefile --noconsole --add-binary "./driver/chromedriver.exe;./driver" --add-data "C:\Users\YOUR_USER_NAME\.conda\pkgs\selenium-3.141.0-py38h2bbff1b_1000\Lib\site-packages\selenium\webdriver\remote;selenium\webdriver\remote"
For item 3, to resolve relative paths in your source code, you can use below function in related places (for example when accessing chromedriver.exe)
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.dirname(__file__)
return os.path.join(base_path, relative_path)
Use above function once you need to access packaged executables and files in your source code. In below example, my chromedriver is inside driver folder in my workspace. But when it is accessed through pyinstaller executable, it will be extracted to temp folder in AppData, yet function will access it through sys._MEIPASS variable set by pyinstaller.
driver = webdriver.Chrome(executable_path = resource_path('./driver/chromedriver.exe'))
Hope it works.
I'm facing a problem right now and I don't really know how to get more informations about it.
I've converted a desktop application through Microsoft's Desktop App Converter, made some manual modifications about the visual assets, and rebundled it through "makeappx.exe". Then I signed it.
Everything went fine. Except that when I double click the appx to check it, I have the following window:
Appx Error
Which roughly translates as "Couldn't open the appx or appxbundle file" and "Reason: Failure caused by an unknown reason".
This does not helps me a lot :/
However, if I try to install the package through a simple "Add-appxpackage MyPackage.appx", it works perfectly fine.
Could anyone help me find some leads on what's happening here? I've already checked the event viewer as explained here but I couldn't find anything unusual.
Thanks,
Skefrep
It seems the Microsoft team has taken notice of this problem and investigated this appropriately.
-Here is their solution-
The problem can be because when you convert an app with DesktopBridge the resources are signed with the manifest info and store that info in the .pri files you found in PackageFiles folder. Later, when you change something like the Publisher or the Name this signature doesn't match. To fix this you only need to recreate the .pri files.
rm *.pri. Remove the old .pri files.
cd C:\foo\PackageFiles\. Change current directory to the PackageFiles folder. This step is important for the next step.
makepri createconfig /cf priconfig.xml /dq en-US. Create a configuration file for the resources.
makepri new /pr "C:\foo\PackageFiles" /cf "C:\foo\PackageFiles\priconfig.xml". Generate the new *.pri files.
Then you can make the package as usual: MakeAppx, etc.
You can find more information about this problem in "Failed due to unknown reasons" error when you try to sideload a Desktop Bridge app - App Consult Team.
In a WPF project I have a block which launch application using:
Process.Start(url);
If it throws an error I would like the application to offer to install the exe the sits on the part of the application folder.
The problem is that I am unable to direct to relative folder in the project in order to launch the application.
Would appreciate any assistance.
Try this. Ensure that your program path is correct at all times.
Process proc = new Process();
proc.StartInfo.FileName = "D:\Program.exe";
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName("D:\Program.exe");
proc.Start();
In my WPF caliburn.micro application, I use ComponentOne's C1DocumentViewer to display a report.
I created in the project a new Folder “Reports” and placed the .xml there. I show the report using C1DocumentViewer. When provide the absolute path to the .xml file, it works fine. But of course I need to use a relative path. So if I make it “../../MyProject/Reports/MyReport.xml”, it works on my machine when I run it in Visual Studio. But not when I publish it using ClickOnce, it just cannot find the file. Same thing if I use “/Reports/MyReport.xml” or “Reports/MyReport.xml”.
When I try to use “Reports/MyReport.xml” when I debug in Visual Studio, it is looking for the path “Reports/MyReport.xml” in bin/Debug of the main project of the solution.
Please help. Here is my code:
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
var rpt = new C1.C1Report.C1Report();
rpt.Load(#"Reports/MyReport.xml", "Recent Files Information");
rpt.DataSource.RecordSource = "MyReportProc(1)";
rpt.Render();
Report = rpt.FixedDocumentSequence;
}
Just a guess. Your problem might be related to the working directory of your process.
When the process refers to a file using a simple file name or relative
path (as opposed to a file designated by a full path from a root
directory), the reference is interpreted relative to the current
working directory of the process.
Check it with Directory.GetCurrentDirectory() when you run your program in Visual Studio and also when you run it after publishing it with ClickOnce.
I have a little GWT/AppEngine Project which uses RPC. Basically I need to get some data from a XML file that resides on the server. But when I use the RPC to read the file in my server-package I am getting a AccessControlException (access denied). Any ideas what the problem is?
//JAXB powered XML Parser
public PoiList readXML() {
try {
unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setEventHandler(new XMLValidEventHandler());
db = (PoiList) unmarshaller.unmarshal(new File("src/com/sem/server/source.xml"));
} catch (JAXBException e) {
e.printStackTrace();
}
return db;
}
java.security.AccessControlException: access denied (java.io.FilePermission \WEB-INF\classes\com\sem\server read)
cheers hoax
I think the problem is that you're trying to read a file that is not located in your working directory. The guidlines for structuring your code in gwt apps are as follows
Under the main project directory
create the following directories:
src folder - contains production Java source
war folder - your web app; contains static resources as well as compiled output
test folder - (optional) JUnit test code would go here
Try moving the file to the war directory (for example /war/resources/myFile.xml) and then open it by
File myFile = new File(System.getProperty("user.dir") + "/resources/myFile.xml");
Usually, when you load a resource that is located in your classpath, you should't use java.io.File. Why? Because it's very much possible, that there is no real file - the classes are often packaged as a .jar file, or even loaded in a completely different way (very likely in the case of AppEngine, though I don't know the details.)
So, if you want to load it directly from your classpath, you can use:
ClassLoader classLoader =
getClass().getClassLoader(); // Or some other way to
// get the correct ClassLoader
InputStream is = classloader.getResourceAsStream("/com/sem/server/source.xml");
Then you can use the input stream in your unmarshaller.