I'm trying to collect the Windows Mobile 10 calls history by using the latest API. I have enabled all possible capabilities for my application, but still I'm getting "Access Denied" error while running this code:
var operation = PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AppEntriesReadWrite);
operation.Completed = (o, ev) =>
{
PhoneCallHistoryStore store = o.GetResults();
PhoneCallHistoryEntryReader reader = store.GetEntryReader();
var operation2 = reader.ReadBatchAsync();
operation2.Completed = (o2, ev2) =>
{
IReadOnlyList<PhoneCallHistoryEntry> callsList = o2.GetResults();
foreach (PhoneCallHistoryEntry entry in callsList)
{
// process calls here
}
};
};
I'm getting the following error message while doing line 4:
An exception of type 'System.UnauthorizedAccessException' occurred in App1.exe but was not handled in user code
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I'm running this code on Mobile Emulator in Visual Studio 2015.
This is what I used for that code:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.calls.aspx
Any idea what can be wrong?
In order to make above code working and view phone call history, need to add the following things:
1) Rescap namespace
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
2) Restricted capability "phoneCallHistory"
<rescap:Capability Name="phoneCallHistory"/>
3) Change PhoneCallHistoryAccessType to AllEntriesLimitedReadAndWrite.
var operation = PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
Thanks to #RaymondChen for giving me the proper capability name.
Related
I have the following code that in some sporadic target machines produce the following exception:
ClassFactory cannot supply requested class (Exception from HRESULT:
0x80040111)
This is the code that produces the exception:
WindowingEnvironment winEnv = WindowingEnvironment.FindAll(WindowingEnvironmentKind.Overlapped).FirstOrDefault();
if (winEnv == null)
return;
IReadOnlyList<DisplayRegion> regions = winEnv.GetDisplayRegions();
List<string> monitorIds = new List<string>();
foreach (DisplayRegion region in regions)
{
if (!region.IsVisible)
continue;
string monitorId = region.DisplayMonitorDeviceId;
if (!monitorIds.Contains(monitorId))
{
monitorIds.Add(monitorId);
Debug.WriteLine(region.WorkAreaSize.ToLTSize());
}
}
This code works fine in all our development machines and in 99.9% of the user base, but in a few sporadic cases, it throws the above-mentioned exception. So, I guess it could be a problem of the target OS or some preferences of the user that would upset one of those APIs.
Please also note that the users experiencing this problem are running the latest Win 10 build.
Do you have any clue of which preferences/settings/etc. could affect this code?
Thank you!
We are trying to develop a new web application for screen scraping from TN3270. We are using visual studio 2015 and HIS 2016.
Following code is written to connect TN3270
var display = new SessionDisplay();
var connection = new SessionConnectionDisplay();
connection.DeviceType = TNDeviceType.IBM3278Model2;
connection.Transport = SessionDisplayTransport.TN3270;
connection.TN3270Port = 23;
connection.TN3270Server = "server name";
connection.HostCodePage = 37;
display.Connect(connection);
The code is working fine when we execute it from console or windows application. But when we try to call from web application, I'm getting the following error:
An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.HostIntegration.SNA.Session.dll but was not handled in user code
Additional information: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
StackTrace
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo)
at Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay.CreateSessionConnection()
at
Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay.ConnectToSessionDisplay(SessionDisplay
connectedSession)
at Microsoft.HostIntegration.SNA.Session.SessionDisplay.Connect(SessionConnectionDisplay
connection)
I would appreciate any help on this.
connection.Implementation = ImplementationDetail.ManagedTn;
setting this property solved my problem.
I have problem with using camera in Windows Phone Silverlight 8.1 application. I want just to initialize camera and see its preview (for now I don't need any photos or video capture). I have found nice and simple example on MSDN and
private CaptureSource captureSource;
private VideoCaptureDevice videoCaptureDevice;
private void InitializeVideoRecorder()
{
try
{
if (captureSource == null)
{
captureSource = new CaptureSource();
var a = captureSource.VideoCaptureDevice;
videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
captureSource.CaptureFailed += OnCaptureFailed;
if (videoCaptureDevice != null)
{
VideoRecorderBrush = new VideoBrush();
VideoRecorderBrush.SetSource(captureSource);
captureSource.Start();
CameraStatus = "Tap record to start recording...";
}
else
{
CameraStatus = "A camera is not supported on this phone.";
}
}
}
catch (Exception ex)
{
CameraStatus = "ERROR: " + ex.Message.ToString();
}
}
The code stops at captureSource.Start(); throwing System.UnauthorizedAccessException: Attempted to perform an unauthorized operation..
First of all I found information (on the same page) that ID_CAP_ISV_CAMERA capability is needed in `WMAppManifest.xml'. But I have problem with adding it, because:
I can't find this capability in designer
I get error when I add it manualy to .xml file
Error reproduced below:
Warning 1 The 'Name' attribute is invalid - The value 'ID_CAP_ISV_CAMERA' is invalid according to its datatype 'http://schemas.microsoft.com/appx/2010/manifest:ST_Capabilities' - The Enumeration constraint failed.
Error 3 App manifest validation failed. Value 'ID_CAP_ISV_CAMERA' of attribute '/Package/Capabilities/Capability/#Name' must be a valid capability.
I have even found the same solution on SO WP8.1 SilverLight Microsoft.Devices.PhotoCamera Access Denied
Can somebody tell me why can't I use original MSDN solution to this problem?
First, it looks like you're trying to add that capability to Package.appxmanifest instead of WMAppManifest.xml. You should be able to find WMAppManifest.xml under Solution Explorer -> <your project> -> Properties:
Opening that file should give you the option to add ID_CAP_* capabilities.
Second, you need to specify both ID_CAP_ISV_CAMERA and ID_CAP_MICROPHONE in order to use CaptureSource.Start(), even if you're only using one of the devices.
I am trying to "Delegate control" for Organizational Unit in Active Directory using c#
I am using the following code:
try
{
using (DirectoryEntry deOU = new DirectoryEntry("LDAP://MYDOMAIN/OU=MYOU", "admin_user_on_domain", "password"))
{
NTAccount acctUser = new NTAccount("some_user");
ActiveDirectoryAccessRule ruleReadWriteProp = new ActiveDirectoryAccessRule((IdentityReference)acctUser, ActiveDirectoryRights.GenericAll, AccessControlType.Allow);
deOU.ObjectSecurity.AddAccessRule(ruleReadWriteProp);
deOU.Options.SecurityMasks = SecurityMasks.Dacl;
deOU.CommitChanges();
Console.Write("DONE");
}
}
catch (Exception ex)
{
//Do something with exception
}
The scenario details:
Windows server 2008 R2.
project target (.net 2.0)
I am running code from my machine connected to the server via LAN.
Code is NOT asp.net code , it`s native c# code.
The code produces the following exception :
System.DirectoryServices.DirectoryServicesCOMException
Message: An operations error occurred.
I tried to run the code Directly on the server ,, the same exception appear , please advice
thanks
try this link http://sanjaymungar.blogspot.com/2010/07/impersonation-in-aspnet-causes.html
add the code between
using (HostingEnvironment.Impersonate())
{
//your code
}
Getting this exception The file size exceeds the limit allowed and cannot be saved when writing to event viewer using EventLog
Code used:
string cs = "LoggingService";
EventLog elog = new EventLog();
if (!EventLog.SourceExists(cs))
{
EventLog.CreateEventSource(cs, cs);
}
elog.Source = cs;
elog.EnableRaisingEvents = true;
elog.WriteEntry(message);
Stack trace:
System.ComponentModel.Win32Exception (0x80004005): The file size exceeds the limit allowed and cannot be saved
at System.Diagnostics.EventLogInternal.get_OldestEntryNumber()
at System.Diagnostics.EventLogInternal.StartRaisingEvents(String currentMachineName, String currentLogName)
at System.Diagnostics.EventLogInternal.set_EnableRaisingEvents(Boolean value)
Things tried:
http://support.microsoft.com/kb/328380#top
When I put this statement elog.Clear() before elog.EnableRaisingEvents = true;
I am getting different exception
System.ComponentModel.Win32Exception (0x80004005): Access is denied
at System.Diagnostics.EventLogInternal.Clear()
The above code is executed by a web service which runs under LocalSystem which has full permission on the computer.
OS: windows server 2008R2 and .NET 4.0
There is a method EventLog.ModifyOverflowPolicy that modifies log policy.
I believe EventLog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded,0) could be helpful.
Event Viewer - Properties - Maximum log size was 1028. I bumped it and it started working fine.
But the same code was working from another window service before I made the above the change.
which make me think what could have happened
The message I was trying to log was just a line (less then 255 characters)