Upgraded to Silverlight 4 cause System.Security.SecurityException - silverlight

Trying to open a file dialog but I get an exception when calling ShowDialog. This pice of code have always worked fine but I think when I upgrade to Silverlight 4 it caused some problem.
Code:
var dlg = new OpenFileDialog { Filter = "CSV Files (*.csv)|*.csv" };
if (dlg.ShowDialog() == true)
{
Upload(dlg.File);
}
Exception:
Directory = 'dlg.File.Directory' threw an exception of type 'System.Security.SecurityException'
{System.Security.SecurityException: File operation not permitted. Access to path file.csv' is denied.
at System.IO.FileSecurityState.EnsureState()
at System.IO.FileInfo.get_DirectoryName()
at System.IO.FileInfo.get_Directory()
}
It seems like it´s problem to get options for the directory because I got correct filename and file size but no information about the directory and directory name.

If you are trying to debug the application then you will get this security exception. Try to run without debugging and check if you are still getting this error.

Related

Serilog - Unable to open file - File used by another process Error

I'm using serilog in a .NetCore 3.1 application.
loggerFactory.AddSerilog();
Log.Logger = new LoggerConfiguration().MinimumLevel.Information()
.WriteTo.File("test-{Date}.txt").CreateLogger();
app.UseSerilogRequestLogging();
When i run a application and try to access file, i'm getting error saying
"File cannot be opened because it is being used by another process"
Am i missing any setting to be added?
Update:
Even after adding shared:true - Did not work.
Log.Logger = new LoggerConfiguration().MinimumLevel.Information()
.WriteTo.Async( o => o.File("test1.txt", shared: true)).CreateLogger();

Drupal Wiris integration

I followed this tutorial to install the Wiris plugin on a new installation of Drupal.
Once the installation was complete and I clicked on the Wiris icon to begin adding a formula, the popup window does NOT load and I get the following error in the console area:
Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Invalid target origin '/DrupalQuiz/sites/all/libraries/ckeditor/plugins/ckeditor_wiris/' in a call to 'postMessage'.
at http://*.*.*.*/DrupalQuiz/sites/all/libraries/ckeditor/plugins/ckeditor_wiris/core/core.js:19:22
The code causing the problem is as follows:
e.source.postMessage(postVariable, _wrs_conf_path);
I'm at a loss how to deal with this issue.
I don't have a complete fix but I was able to get it working locally by replacing _wrs_conf_path with the base path of my dev box. _wrs_conf_path was evaluating to a relative path to the plugins folder.
if (typeof(e.source) != 'undefined') {
e.source.postMessage(postVariable, _wrs_conf_path);
}
with
if (typeof(e.source) != 'undefined') {
e.source.postMessage(postVariable, _wrs_currentPath);
}
in the /sites/all/libraries/ckeditor/plugins/ckeditor_wiris/core/core.js file.
Edit: I replaced _wrs_conf_path with one of their internal variables _wrs_currentPath and that seemed to fix the issue.

How to use ReactiveUI with WinForms

I have decided to learn ReactiveUI after seeing what can be done with it, but my enthusiasm has been broken at the first attempt to run a simple project. I have recreated the example from this article, using reactiveui-winforms.Net40 version 6.5.0 from NuGet. Everything compiles ok, but i get an exception during runtime at the following line
var OKCmdObs = this.WhenAny(vm => vm.EnteredText,
s => !string.IsNullOrWhiteSpace(s.Value));
System.InvalidOperationException occurred
HResult=-2146233079
Message=The current thread has no Dispatcher associated with it.
Source=System.Reactive.Windows.Threading
StackTrace:
at System.Reactive.Concurrency.DispatcherScheduler.get_Current()
at ReactiveUI.PlatformRegistrations.<>c.<Register>b__0_7() in C:\workspace\git-perso\ReactiveUI\ReactiveUI\Platform\Registrations.cs:line 75
InnerException:
Does anyone have any idea of what's happening ?
The mentioned article does not have the compiled project available for download, and i didn't find any complete "Hello-World" project for reactiveui-winforms.
My test project can be downloaded here.
In Visual Studio, if i Continue(F5), another exception occures :
System.NullReferenceException occurred
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ReactiveUI
StackTrace:
at ReactiveUI.IROObservableForProperty.<>c__DisplayClass1_0.<GetNotificationForProperty>b__6(IReactivePropertyChangedEventArgs`1 x) in C:\workspace\git-perso\ReactiveUI\ReactiveUI\IROObservableForProperty.cs:line 44
InnerException:
If i continue to hit F5 i get :
System.Exception was unhandled by user code
HResult=-2146233088
Message=An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Source=ReactiveUI
This exception is caused because RxUI always tries to initialize for WPF, even though (because you're also using the winforms package) it'll override this setting with a Winforms-based scheduler right after.
It should be harmless though, as it's catched and ignored. You're probably hitting it within VS ?

.NET application fails to run from Network Share and RDP Shell

I'm trying to run my .NET application, that resides in a network share from our domain, using a RDP Client.
When starting a "full" RDP session (that is, opening the whole desktop) and then running my application from the .exe file, everything works fine.
But when I set this same .exe as the Startup Application Path from the RDP Client , I get the following error:
(PS: I clipped the stack trace to the calls I found myself more important)
System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception. ---> System.ArgumentException: Incorrect Parameter. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
(...)
at System.AppDomain.get_Evidence()
(...)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NHibernate.Cfg.Environment.LoadGlobalPropertiesFromAppConfig() in p:\nhibernate-core\src\NHibernate\Cfg\Environment.cs:line 212
at NHibernate.Cfg.Environment..cctor() in p:\nhibernate-core\src\NHibernate\Cfg\Environment.cs:line 198
As I work with shadow-copied files, I set a new AppDomain when the application has just begun (the .exe entry point):
<STAThread()>
Public Sub Main()
Try
Dim currentDirectory As DirectoryInfo = New DirectoryInfo(Directory.GetCurrentDirectory)
Dim runtimeDirectory As DirectoryInfo = New FileInfo(Assembly.GetExecutingAssembly.Location).Directory
Dim appDomainStartupSetup As New AppDomainSetup
appDomainStartupSetup.ApplicationBase = currentDirectory.FullName
appDomainStartupSetup.ShadowCopyFiles = "true"
Dim appDomainStartup As AppDomain = AppDomain.CreateDomain("StartupAppDomain", Nothing, appDomainStartupSetup)
Dim entrypointLoader As LoadBaseFiles = appDomainStartup.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly.CodeBase, "MyClass.LoadBaseFiles")
entrypointLoader.RuntimeDir = runtimeDirectory.FullName ' Setup the 'entry-point' object
entrypointLoader.StartupEntryPoint() ' Starts the Application
Catch ex As Exception
' Error Handling Here
End Try
End Sub
Public Class LoadBaseFiles
Inherits MarshalByRefObject
' Startup stuff here...
End Class
More Info
Content of my ApplicationEntryPoint.exe.config file;
I had set the CAS Policy to Full Machine Trust, but I'm not sure this still applies to .NET 4.0;
The Remote Desktop (Terminal Services) Server runs Windows Server 2003;
EDIT:
If I copy all the assemblies to a local drive (C:) and run my application from there, it will work fine.
Any advices?
It looks like you're missing an argument or pointing to an unavailable resource.
a) Is the Working Directory set for the application?
b) Is the Working Directory available to the user on login?

bug in aspnet_compiler?

I have a solution with several web projects.
I have built each project into its own folder (there's about 10 projects):
/build/projA
/build/projB
/build/projC
If I call
aspnet_compiler -v / -p \"build/#{proj}\" merged/#{proj}
on each one in turn, everything is fine.
If I make all 10 calls to aspnet_compiler in parallel, I get assembly loading errors, saying the referenced assemblies are in use.
Is this a bug? Why would it be in use? It shouldn't be.
The assemblies that cant be loaded are in multiple projects, but each one has its own copy in its bin folder.
Update: it seems to occur (for some) of the assemblies that are references of references. Those loaded with complete binding information seem to work.
Here's a dump from one of the failed loadings from fuslogvw
The operation failed.
Bind result: hr = 0x80070020. The process cannot access the file because it is being used by another process.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = andrew.bullock
LOG: DisplayName = Yahoo.Yui.Compressor
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Yahoo.Yui.Compressor | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///E:/build/ProjA/
LOG: Initial PrivatePath = E:\build\ProjA\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\src_projects_proja\061ad2e7
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\src_projects_proja\061ad2e7
LOG: AppName = 627cc9a9
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\build\ProjA\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/src_projects_proja/061ad2e7/627cc9a9/Yahoo.Yui.Compressor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/src_projects_proja/061ad2e7/627cc9a9/Yahoo.Yui.Compressor/Yahoo.Yui.Compressor.DLL.
LOG: Attempting download of new URL file:///E:/build/ProjA/bin/Yahoo.Yui.Compressor.DLL.
LOG: Assembly download was successful. Attempting setup of file: E:\build\ProjA\bin\Yahoo.Yui.Compressor.dll
LOG: Entering download cache setup phase.
ERR: Error extracting manifest import from file (hr = 0x80070020).
ERR: Setup failed with hr = 0x80070020.
ERR: Failed to complete setup of assembly (hr = 0x80070020). Probing terminated.
If you call the ClientBuildManager directly, outside of aspnet_compiler there doesn't seem to be a problem, no idea why.
var parameter = new ClientBuildManagerParameter
{
PrecompilationFlags = PrecompilationFlags.ForceDebug
};
var client = new ClientBuildManager("/", src, dest, parameter);
client.PrecompileApplication();

Resources