Internal Server Error on FindItems for Public Folders - exception

I've a simple VB.NET application to get all items on a Public Contact Folder. I know that this code works for many years. We upgraded on our OnPremise Exchange 2013 to CU23 for a few month and installed the Hafnium patches (BTW: Our server was not compromised and is not attached directly to the internet).
I think after this upgrade (But I'm not pretty sure) we have the problem that the request "FindItems" on a PublicFolder "Kontakte (Global)" returns an Internal Server Error. Here is the code:
Dim objExchangeService As New ExchangeService
objExchangeService.Credentials = objCredentials
objExchangeService.Url = New Uri(strExchangeUrl)
Dim objFolderView As New FolderView(intBatchSize, intFoldersOffset)
Dim objFolders As FindFoldersResults = objExchangeService.FindFolders(WellKnownFolderName.PublicFoldersRoot, objFolderView)
Dim objGlobalContacts As Folder = objFolders.FirstOrDefault(Function(objFolder) "Kontakte (Global)".Equals(objFolder.DisplayName, StringComparison.InvariantCulture))
Dim objView As New ItemView(Int32.MaxValue)
objExchangeService.FindItems(objGlobalContacts.Id, objView) ' Exception here -> Internal Server Error
We got this Exception:
Microsoft.Exchange.WebServices.Data.ServiceResponseException: Interner Serverfehler. Fehler bei diesem Vorgang.
bei Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
bei Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
bei Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
bei Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
bei Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems[TItem](IEnumerable`1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, ViewBase view)
Has anybody an idea whats wrong?

What if you try to just get the last item in the folder eg
Dim objView As New ItemView(1)
objExchangeService.FindItems(objGlobalContacts.Id, objView)
You shouldn't be doing
Dim objView As New ItemView(Int32.MaxValue)
as throttling will stop you getting more then 1000 items by default anyways so you should be paging but I would first test just trying to get 1 item. You could also do some testing using the EWSEditor https://github.com/dseph/EwsEditor/releases outside of what your code is doing which is even easier then changing your code.

I tried it with ItemView(1) and got the same error. I used the EWSEditor but I cannot see any option to get items from the public folders.
In the meanwhile I checked the error log of the EWS folder. I got the exception:
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.GlobalServiceUrls.GetInternalUrl[Service](String serverFqdn)
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.HttpProxyBackEndHelper.GetBackEndServiceUrlByServer[ServiceType](BackEndServer backEndServer)
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator.CallWithExceptionHandling[T](Func`1 actualCall)
bei Microsoft.Exchange.Services.Core.EwsClientHelper.DiscoverEwsUrl(IMailboxInfo mailbox)
bei Microsoft.Exchange.Services.Core.RemotePublicFolderOperations.Execute[T](Boolean writeOperation CallContext callContext RemoteExecute`1 executeEWSOperation)
bei Microsoft.Exchange.Services.Core.RemotePublicFolderOperations.GetFolderReplica(CallContext callContext Byte[] folderIdBytes)
bei Microsoft.Exchange.Services.Core.Types.IdConverter.ServerInfoFromIdHeaderInformation(CallContext callContext IdHeaderInformation header Boolean isHierarchyOperations)
bei Microsoft.Exchange.Services.Core.Types.ServiceObjectId.InitServerInfo(Boolean isHierarchicalOperation)
bei Microsoft.Exchange.Services.Core.Types.BaseRequest.EvaluateMailboxMetrics(List`1 ids Boolean isHierarchicalOperation)
bei Microsoft.Exchange.Services.Core.Types.BaseRequest.Submit[T](AsyncCallback hostCallback Object hostState)
bei AsyncInvokeBeginBeginFindItem(Object Object[] AsyncCallback Object )
bei System.ServiceModel.Dispatcher.AsyncMethodInvoker.InvokeBegin(Object instance Object[] inputs AsyncCallback callback Object state)
bei System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet);
FaultInnerException=Microsoft.Exchange.Services.Core.Types.InternalServerErrorException: Interner Serverfehler.
Fehler bei diesem Vorgang. --->
Microsoft.Exchange.Data.ApplicationLogic.VDirConfigurationMissingException:
Das virtuelle Clientzugriffsverzeichnis-Objekt mit InternalUrl gestempelt für den -Dienst konnte nicht gefunden werden. Letzter überprüfter Server: EXCHANGE. (MEANS: Could not locate Client Access Virtual Directory object with InternalUrl stamped for service)
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.GlobalServiceUrls.DiscoverUrlsIfNeeded()
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.GlobalServiceUrls.GetInternalUrl[Service](String serverFqdn)
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.HttpProxyBackEndHelper.GetBackEndServiceUrlByServer[ServiceType](BackEndServer backEndServer)
bei Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator.CallWithExceptionHandling[T](Func`1 actualCall)
bei Microsoft.Exchange.Services.Core.EwsClientHelper.DiscoverEwsUrl(IMailboxInfo mailbox)
bei Microsoft.Exchange.Services.Core.RemotePublicFolderOperations.Execute[T](Boolean writeOperation CallContext callContext RemoteExecute`1 executeEWSOperation)
bei Microsoft.Exchange.Services.Core.RemotePublicFolderOperations.GetFolderReplica(CallContext callContext Byte[] folderIdBytes)
bei Microsoft.Exchange.Services.Core.Types.IdConverter.ServerInfoFromIdHeaderInformation(CallContext callContext IdHeaderInformation header Boolean isHierarchyOperations)
bei Microsoft.Exchange.Services.Core.Types.ServiceObjectId.InitServerInfo(Boolean isHierarchicalOperation)
bei Microsoft.Exchange.Services.Core.Types.BaseRequest.EvaluateMailboxMetrics(List`1 ids Boolean isHierarchicalOperation)
bei Microsoft.Exchange.Services.Core.Types.BaseRequest.Submit[T](AsyncCallback hostCallback Object hostState)
I think there must be something wrong with the Internal URLs and I checked our URLs with:
Get-ActiveSyncVirtualDirectory (No Internal URL set)
Get-AutodiscoverVirtualDirectory (No Internal URL set)
Get-EcpVirtualDirectory (Internal URL set)
Get-MapiVirtualDirectory (Internal URL set)
Get-OabVirtualDirectory (Internal URL set)
Get-OwaVirtualDirectory (Internal URL set)
Get-PowerShellVirtualDirectory (Internal URL set)
Get-WebServicesVirtualDirectory (Internal URL set)
Maybe this error belongs to: https://learn.microsoft.com/de-de/troubleshoot/dynamics-365/sales/issue-when-adding-to-outlook-error-when-deploying-dynamics-365-app-for-outlook - Because I got the same error. I will check the URLs today or tomorrow evening.

I found the solution. In my case the InternalURL of the ActiveSyncVirtualDirectory was not preset. That means if I enter "Get-ActiveSyncVirtualDirectory" it returns nothing.
I found the solution here: https://serverfault.com/questions/916154/virtual-directory-activesync-exchange-2010-its-there-its-not-there
In my Active Directory there was no object "Microsoft-Server-ActiveSync (Default Web Site)" but in the IIS the website exists. I cannot create a new virtual directory because there exists an orphaned configration.
I did this to remove the orphaned IIS configuration (https://serverfault.com/questions/916154/virtual-directory-activesync-exchange-2010-its-there-its-not-there - Second answer):
OK I finally have this one resolved, I want to share the solution in case someone else runs into it. Everything that follows here requires full Admin rights.
Please run from powershell (on the exchange server)
$Site = [ADSI]"IIS://localhost/W3SVC/1/Root/Microsoft-Server-ActiveSync"
and then run
$site
Result:
distinguishedName:
Path: {C:\Program Files\Microsoft\Exchange Server\V14\Client Access\Sync}
Next run:
$Site = [ADSI]"IIS://localhost/W3SVC/1/Root"
$site.Delete("IIsWebVirtualDir","Microsoft-Server-ActiveSync")
$site.SetInfo()
This will remove the phantom virtual directory.
Now run:
iisreset
Now run:
New-activesyncvirtualdirectory -websitename "Default Web Site"
it should recreate the new virtual directory.
Run iisreset again, and edit the internal and external URL's
Then go get yourself a cold one.
After these steps I got no errors on the "Apps" Tab and my code works. I think during this problem occurs during the CU update.
Best regards
Rainer

Related

Showing error or success message on same page

this is my first time posting here since I couldn't figure the issue out, please keep in mind im fairly new to Spring and not that good at Java and coding in general.
I'm trying to program a Server application with Java Spring where you're able to create different accounts with specific roles. I want my users to be able to see a success or error message on the same page if the creation of an account succeded or failed.
Right now I'm using the error.param th:if tag from https://spring.io/guides/gs/securing-web/
the specific code in my HTML file is:
<div id="error" th:if="${param.error}">
Benutzername existiert bereits.
</div>
<div id="success" th:if="${param.success}">
Das Konto wurde erfolgreich erstellt.
</div>
Which works when I manually put ?success or ?error behind my URL.
I map my POST to the database by this method:
#PostMapping("/create/lieferant/fahrer")
public String submitDriver(#ModelAttribute Driver driver){
if(userRepository.existsByUsername(driver.getUsername())){
return "create/lieferant/fahrer?error";
}
Driver d = new Driver();
User n = new User();
Role r = new Role();
d.setName(driver.getName());
d.setTelnum(driver.getTelnum());
d.setUsername(driver.getUsername());
n.setUsername(driver.getUsername());
n.setPassword(encoder().encode(driver.getPassword()));
r.setUsername(driver.getUsername());
r.setAuthority("LIEFERANT");
userRepository.save(n);
driverRepository.save(d);
roleRepository.save(r);
return "create/lieferant/fahrer?success";
}
The idea is to check if the username is already registered and if so, returning the create/lieferant/fahrer?error but it says
Error resolving template "create/lieferant/fahrer?error", template
might not exist or might not be accessible by any of the configured
Template Resolvers
and the same for ?success.
What I don't understand is: it's working for the login which I've gotten from the Spring getting started guide and it seems to be working without any heavy configurations or so. Atleast I don't see any.
I'd be glad if anyone could help me figuring my issue out.
Thanks a lot.
You could do something like this:
#PostMapping("/create/lieferant/fahrer")
public ModelAndView submitDriver(#ModelAttribute Driver driver){
ModelAndView mav = new ModelAndView();
mav.setViewName("create/lieferant/fahrer");
try {
if(userRepository.existsByUsername(driver.getUsername())){
return "create/lieferant/fahrer?error";
}
Driver d = new Driver();
User n = new User();
Role r = new Role();
d.setName(driver.getName());
d.setTelnum(driver.getTelnum());
d.setUsername(driver.getUsername());
n.setUsername(driver.getUsername());
n.setPassword(encoder().encode(driver.getPassword()));
r.setUsername(driver.getUsername());
r.setAuthority("LIEFERANT");
userRepository.save(n);
driverRepository.save(d);
roleRepository.save(r);
mav.addObject("success", "All was ok");
} catch (Exception e) {
mav.addObject("error", "Error message to change");
}
return "create/lieferant/fahrer?success";
}
You could retrieve messages on page with the two keys "success" and "error"

How to Include a reference to a table in Invantive Excel add-in

I'm making a financial report in Excel using the data from Exact Online using the Invantive Control Excel Add-in. In Exact Online I have a classification for the General Ledgers. In my Excel file, I would like to match these classifications on my reporting schedule. Therefore, I made a table with a mapping of the Exact Online classifications and the reporting classifications.
Using the Invantive Control Excel add-in, I entered the following SQL query:
select periods_year_reportingyear_attr
, reportingperiod_attr
, division_code
, division_hid
, division_name
, periods_year_years_balance_code_attr
, periods_year_years_balance_description
, '=I_EOL_GL_ACTCLN_CODE($C{E,.,.,^+2,.}, $C{E,.,.,^+5,.})' verdichting_code
, '=I_EOL_GL_ACTCLN_DESCRIPTION($C{E,.,.,^+2,.}, $C{E,.,.,^+5,.})' verdichting_naam
, '=i_eol_bal_year_open($C{E,.,.,^+2,.} , $C{E,.,.,^,.}, $C{E,.,.,^+5,.}) + if($C{E,.,.,^+1,.} = 1, 0, i_eol_bal_pder($C{E,.,.,^+2,.},$C{E,.,.,^,.},1,$C{E,.,.,^+1,.}-1,$C{E,.,.,^+5,.}))' startsaldo
, balance
, '=i_eol_bal_year_open($C{E,.,.,^+2,.} , $C{E,.,.,^,.}, $C{E,.,.,^+5,.}) + i_eol_bal_pder($C{E,.,.,^+2,.},$C{E,.,.,^,.},1,$C{E,.,.,^+1,.},$C{E,.,.,^+5,.})' eindsaldo
, periods_year_years_balance_balancetype_attr
, '=INDEX(tab_reporting[Reporting],MATCH(NUMBERVALUE(I_EOL_GL_ACTCLN_CODE($C{E,.,.,^+2,.}, $C{E,.,.,^+5,.})),tab_reporting[GL Class - Code],0))' reporting
from balancelinesperperiod
order
by periods_year_reportingyear_attr
, reportingperiod_attr
, division_hid
, periods_year_years_balance_code_attr
In which tab_reporting is the name of a table with de mapping of the reporting classifications and the Exact Online. This table is on a different tab within Excel. When I review the data I will see these results:
Which, to me looks oke.
One thing that I don't understand is that it looks like there are 4 fields on position 14. The one formula appears to create 4 different data fields in stead of one.
I could send the Excel file upon request.
The problem is that I end up with this error message:
itgensdf031: Kan velden van blok 'Balans (bal)' niet verversen. Can
not refresh fields completely. The field '});TAB_REPORTING[GL CLASS -
CODE];0))'' has a Formule which will get lost when the field is
deleted since it no longer occurs in the SQL.
Migrate all relevant field settings that you need to keep and would
get lost when this field is removed. Hire a consultant if you don't
know how to do this.
Type: Invantive.Data.ValidationException at
Invantive.Data.ValidationException..ctor(String messageCode, String
messageText, String kindRequest, String localStackTrace, String nk,
Exception innerException) at
Invantive.Producer.Control.Utility.RefreshFields(ModelCache
modelCache, iea_blocks_v block, Boolean allowLoadFromCache) at
Invantive.Producer.Control.SyncToDatabaseForm.syncBackGroundWorker_DoWork(Object
sender, DoWorkEventArgs e) at
System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object
argument) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink) at
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object
o) at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object
state) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() at
Invantive.Producer.Control.Utility.RefreshFields(ModelCache
modelCache, iea_blocks_v block, Boolean allowLoadFromCache) in
File173:line 4362 at
Invantive.Producer.Control.SyncToDatabaseForm.syncBackGroundWorker_DoWork(Object
sender, DoWorkEventArgs e) in File174:line 299 Type:
Invantive.Data.ValidationException at
Invantive.Data.ValidationException..ctor(String messageCode, String
messageText, String kindRequest, String localStackTrace, String nk,
Exception innerException) at
Invantive.Producer.Control.SyncToDatabaseForm.syncBackGroundWorker_DoWork(Object
sender, DoWorkEventArgs e) at
System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object
argument) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink) at
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object
o) at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object
state) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Invantive Control for Excel (stable-20161021-2025-ge3e5e61 Prod,
L162135034)
It seems that you have managed through a bug somewhere to create multiple fields at position 14. This is a corruption of the repository.
I recommend to first remove the fields at position 14 by:
unchecking their properties
remove the part from the SQL that defines the fields at position 14 (save it somewhere),
and then pressing Refresh in the fields tab.
Check that the fields at position 14 are gone.
The re-add the part from the SQL that defines the fields at position 14.
It should work again.

How to use a singleton for storing the RedisConnection with Booksleeve?

I'm using Booksleeve 1.1.0.6 (the latest nuget package).
I want so use a single connection for my whole Web Application so I'm storing it in a singleton:
public static RedisConnection Conn = RedisConfig.GetUnsecuredConnection(waitForOpen: true);
The RedisConfig.GetUnsecuredConnection method is the same as used in BookSleeve tests.
When I try to do an operation I get an InvalidOperationException: The queue is closed exception:
[InvalidOperationException: The queue is closed]
BookSleeve.MessageQueue.Enqueue(RedisMessage item, Boolean highPri) in C:\Dev\BookSleeve\BookSleeve\MessageQueue.cs:73
BookSleeve.RedisConnectionBase.ExecuteVoid(RedisMessage message, Boolean queueJump) in C:\Dev\BookSleeve\BookSleeve\RedisConnectionBase.cs:794
ASP.welisten_booksleevetests_aspx.SaveDictionaryToRedis(Dictionary`2 dictionary) +173
ASP.welisten_booksleevetests_aspx.Page_Load(Object sender, EventArgs e) +67
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
I tried this with the waitForOpen parameter set to true and false
Here is the code I'm trying to execute:
private void SaveDictionaryToRedis(Dictionary<string, string> dictionary)
{
using (Mp.Step("Saving Data to Redis"))
{
using (RedisConfig.Conn)
{
RedisConfig.Conn.Strings.Set(DB, dictionary);
}
}
}
Depending on what was copied, it could be that there is a missing call to:
theConnection.Open();
which will open the connection and perform various handshakes. Thin the case of a singleton, this would be reasonable to do during the initializer.
However! Perhaps the problem here is that your second example is simply wrong. If Conn is, as described, a singleton - then it does not belong to that code, and you should not be using using. That would mean it is only usable once, and all subsequent access would fail. Just access the connection; no using here.

Operation not permitted on IsolatedStorageFileStream

I'm building this WP7 app that uses a video game API to get the statistics of someone's character (just to help learn silverlight). It grabs the players details from the web service and stores them on isolated storage on the phone to relieve strain from the server.
Originally I had a class which had both the cache writing and reading function, but now i've had to seperate it out into two seperate classes. The cache writing class doesn't matter at the moment, just the cache reading class.
On line 7, it throws an exception saying "Operation not permitted on IsolatedStorageFileStream.", but only during the second time it instantiates the class. I've done some checking with debug and it says the file definately exists, but it stops after the second using clause.
Can anyone help me with this please? I feel like I'm missing something really obvious.
public class CacheReader
{
public PlayerData GetPlayerData(string gamertagIn)
{
using (IsolatedStorageFile CachedReachData = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = CachedReachData.OpenFile(gamertagIn + ".xml", FileMode.Open))
{
Debug.WriteLine("Data Retrieved from cache");
XmlSerializer serializer = new XmlSerializer(typeof(PlayerData));
PlayerData loadedPlayer = (PlayerData)serializer.Deserialize(stream);
return loadedPlayer;
}
}
}
}
[EDIT 1]
This is the stack trace i get:
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile(String path, FileMode mode, FileAccess access)
at ReachPhoneApp.CacheReader.GetPlayerFromCache(String gamertagIn)
at ReachPhoneApp.Page2.GetPlayerData()
at ReachPhoneApp.Page2.cacheWriter_UpdateComplete()
at ReachPhoneApp.CacheWriter.WritePlayerDataToCache(String fileNameIn, Object objectIn)
at ReachPhoneApp.CacheWriter.client_GetGameHistoryCompleted(Object sender, GetGameHistoryCompletedEventArgs e)
at ReachPhoneApp.ReachAPI.ReachApiSoapClient.OnGetGameHistoryCompleted(Object state)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
Check that you don't somehow have two threads accessing IsolatedStorage at the same time (ie. in VS Debug.View.Threads and verify that at the time of the exception you don't have multiple paths through the same IsoStore code).
This happened in my WP7 code once every few days and was tricky to find, as it seemed to occur only when not connectected to the debugger.
You need to call:
stream.Close();
before
return loadedPlayer;
I think the problem is that you didn't specify that multiple threads could read/write at the same time by specifying a System.IO.FileShare.ReadWrite or whatever access you need as the last parameter of OpenFile.
See the discussion here on the Microsoft Forums.
I ran into this issue as well, but for completely different reasons as mentioned above. I hadn't created the directory that I was saving into.
private void SaveStringDataToStorage(string sDirectory, string sFileName, string sFileContent)
{
string sPath;
//
using (IsolatedStorageFile oFile = solatedStorageFile.GetUserStoreForApplication())
{
if (!oFile.DirectoryExists(sDirectory))
oFile.CreateDirectory(sDirectory);
//
sPath = Path.Combine(sDirectory, sFileName);
//
using (var oWriter = new StreamWriter(new IsolatedStorageFileStream(sPath, FileMode.Create, oFile)))
oWriter.Write(sFileContent);
}
}
Using this code will work if you had the same problem as me, plus it's pretty simple so you can adapt it to whatever you need. I was using this code before I had issues, but I'd forgotten the ! so the directory was never created haha. Just typical. Hope this helps :)
EDIT
Looking closer at the original question, it may be that the file didn't exist. I think it's always best to do IsolatedStorageFile.DirectoryExists() and IsolatedStorageFile.FileExists() before trying to access either location, whether you are reading or writing.
By default when you use IsolatedStorageFile.OpenFile("filename", FileMode.Open) your file gets locked by this thread and no other thread would be able to access this file until 1st thread close it. But if you like to share your file in multiple threads for read purpose only then I would recommend you to use following override
IsolatedStorageFile.OpenFile("filename", FileMode.Open, FileAccess.Read, FileShare.Read)
see details here

Getting an exception when site is pushed to production

This is probably a shot in the dark but here goes nothing...
I have a Sitecore 6 site that I am developing locallty. When I pushed it to the production server, I now get an exception when trying to access the site. I had done an upgrade of the Sitecore version, and added the Forms module, among some other minor edits. So I moved everything to production, changed the connection strings, and changed the directory references in the web.config, but I still get this error.
My local machine still works fine, and even my staging server (hooked up via SVN and Cruise Control) works fine, but I can't fix this error on production.
At the bottom of the stack trace (below), it looks like it is trying to instantiate the search manager. Maybe that has something to do with it?
Or maybe I missed a setting when I moved everything? What settings need to be changed when the environment changes?
Here is what I've tried so far:
Re-copied all of the files and databases.
Gave full control permissions to the worker process, ASPNET, and Network Service users.
Double checked the directory paths in the web.config that needed to be configured.
Double checked the connection string in the connectionstring.config.
Recycled the App Pool
Stopped and started the site
Cleared my local browser cache (as they instruct you to do in the upgrade docs)
This is the exception that is being thrown when I try and access any page:
Thread information:
Thread ID: 1
Thread account name: 180716WEB1\testcom_web
Is impersonating: False
Stack trace: at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at Sitecore.Reflection.ReflectionUtil.SetProperty(Object obj, PropertyInfo property, Object value)
at Sitecore.Reflection.ReflectionUtil.SetProperty(Object obj, String name, Object value)
at Sitecore.Configuration.Factory.AssignProperties(Object obj, Object[] properties)
at Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.CreateObject(String configPath, Boolean assert)
at Sitecore.Search.SearchManager..cctor()
Custom event details:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
It seems that there's something wrong with rights.
Make sure that you run the right identity(NETWORK SERVICES) in your AppPool and that you follow the Sitecore Installation instructions which can be found on SDN:
Kind regards,
Alex de Groot
Sitecore Solution Architect
It turned out to be that when I restored the database to production, it didn't re-associate the database user with it!!! Stupid me! For whatever reason, that causes this error to occur. I'm guessing that the SearchManager is setup as some sort of external service or something, to abstract things.
I got this error after moving a site between environments. The cause was the path for the sc.variable named dataFolder was incorrect. The value was a full file path and the site was in a different location on the new server.
<sc.variable name="dataFolder" value="c:\www\website\data\" />
Updating the web.config with the correct path fixed the problem.