This project is read-only.

Exception has been thrown by the target of an invocation!

Jun 26, 2009 at 3:52 PM

Hi Fahadaz and all the people here. I need your help.

 

Well, I'm trying to deploy my application on the server (Windows Server 2008). Here in my laptop all is working right.

Then, after installing .NET 3.5 SP1 and IIS7, configured my application in port 80, Integrated Mode, granted rights to Network Service (the account wich is running the app) on the app folder and all subfolders. Ensured all required dlls are in bin folder (Enyim.Caching.dll, MemcachedProviders.dll and log4net.dll) and all are the lastest version from here.

MemCacheD service is running good in two servers on port 11212 and, to avoid problems, I had added a Firewall rule allowing the port that it's using.

 

My Web.config is the same as in the development machine (all SectionGroups, configs and other things are there). Here are the MemCacheD settings:

 

    <enyim.com>

        <memcached>

            <servers>

                <add address="SERVER1-NAME" port="11212"/>

                <add address="SERVER2-NAME" port="11212"/>

            </servers>

            <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00"/>

        </memcached>

    </enyim.com>

    <cacheProvider defaultProvider="MemcachedCacheProvider">

        <providers>

            <add name="MemcachedCacheProvider" type="MemcachedProviders.Cache.MemcachedCacheProvider, MemcachedProviders" defaultExpireTime="2000"/>

        </providers>

    </cacheProvider>

    <system.web>

        <sessionState cookieless="false" timeout="20" regenerateExpiredSessionId="true" mode="Custom" customProvider="MemcachedSessionProvider">

            <providers>

                <add name="MemcachedSessionProvider" type="MemcachedProviders.Session.SessionStateProvider, MemcachedProviders" dbType="None" writeExceptionsToEventLog="false"/>

            </providers>

        </sessionState>

    </system.web>

 

 

I'm not using Db backup, only the in memory cache for SessionState. It's workign very good in development.

I'm not using log4net (i tried adding it to bin folder too, but the error is the same). All dlls are in bin folder...

 

The complete error when I try to run the app (in localhost or externaly) is:

 

 

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Exception has been thrown by the target of an invocation.

Source Error: 

Line 100:        <sessionState cookieless="false" timeout="20" regenerateExpiredSessionId="true" mode="Custom" customProvider="MemcachedSessionProvider">

Line 101:            <providers>

Line 102:                <add name="MemcachedSessionProvider" type="MemcachedProviders.Session.SessionStateProvider, MemcachedProviders" dbType="None" writeExceptionsToEventLog="false"/>

Line 103:            </providers>

Line 104:        </sessionState>

 

 

And now? What can I do? I'm losted!

 

Thanks in advance!

 

Regards,

Erick.

Jun 26, 2009 at 4:52 PM

Hi Erick,
Are you using memcached 1.2 release version or are using the latest code from TFS. If later is true, it has
performance counters. And in development they are created by VS.net. But in production you will have to create it as ASP.net
user has access to update/read for performance counters not create them. You can take the code of create the performance
counter and run it though a windows console app.

Thanks,
Fahad

Jun 26, 2009 at 6:31 PM

Hi Fahad,

Thanks for the help, but I'm using the 1.2 release. To ensure, I had downloaded exactly now from the link http://memcachedproviders.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=10468#DownloadId=37885 and replaced the dlls in my bin folder. The error continue...

Do you have any other ideas?

Thanks one more time.

Regards,

Erick.

Jun 27, 2009 at 5:01 PM

Sorry for getting back a bit late. First thing is to check the permission on the dlls. Copied dll my not have
folder's permission. This happens on our Win 2008 and Win 2003 servers in
production.

Second is to check if you can access the memcached from the server. Simple way to test is to use telnet
:>telnet SERVER1-NAME 11211
:>stats

If this is successful, them memcached is working. Please try these thing. If it is not successfuly please let me know.
Will try other things.
- Fahad 

Jul 10, 2009 at 10:25 PM

I am having this exact issue when deploying to Windows Server 2003.  I have verified that memcached is running and can be accessed.

Did you resolve this issue? Also, can you explain what you mean by "First thing is to check the permission on the dlls. Copied dll my not have
folder's permission.". Which dll's?

Thanks,

Brian

Jul 11, 2009 at 4:05 PM

Check permissions on the dlls in bin folder of the application. When you copy dlls into the bin folder it does not inherit permissions and can't be executed.
- Fahad

Jul 11, 2009 at 7:17 PM

Hello!

Sorry for arriving late...

But yes, I had solved my problem. The permissions on the dlls in bin folder are usefull, but not the only problem.

I remembered that I was with 2 MemCacheD servers running and both configured in Web.config (SERVER1-NAME and SERVER2-NAME), as we can see in my first post.

But my application in SERVER1-NAME couldn't access SERVER2-NAME instance, because of my IIS account doens't had permissions to access it in the other server.

To solve, I created a new Windows account on both servers, with the same name and password. Then, I changed my Application Pool to run with this new account and: all fine!

Thanks for the help, Fahad, and I hope this can help rawdrib.

Regards, Erick.

Aug 5, 2009 at 11:21 AM
Edited Aug 5, 2009 at 11:23 AM

I have followed all the instructions provided and read through all the posts on this issue but cannot even get it working in VS.

  • I have verified memcached is running thru telnet
  • I have added the processModel line to machine.config
  • I have verified the dll's have full controll
  • The performance counters were not created by VS so I created them manually as per the code (did not help), then recompiled the providers with the performance counters removed (did not work)

Here is my config:

<enyim.com>

<memcached enabled="true">

<servers>

<add address="127.0.0.1" port="11211" />

<servers>

<socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:10:00" deadTimeout="00:02:00" />

<memcached>

<enyim.com>

<system.web>

<sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="MemcachedSessionProvider">

<providers><add name="MemcachedSessionProvider" type="MemcachedProviders.Session.SessionStateProvider, MemcachedProviders" connectionStringName="Development-localhost" dbType="SQL" writeExceptionsToEventLog="false" /><providers>

<sessionState>

</system.web>

 

My Exception is:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Exception has been thrown by the target of an invocation.

Source Error:

Line 159:    <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="MemcachedSessionProvider">
Line 160:      <providers>
Line 161:        <add name="MemcachedSessionProvider" type="MemcachedProviders.Session.SessionStateProvider, MemcachedProviders"
Line 162:          connectionStringName="Development-localhost" dbType="SQL" writeExceptionsToEventLog="false" />
Line 163:      </providers>

Is there a way of debugging the provider? I added it to my solution yet can't seem to be able to step into it. Any help would be great...

 

Aug 5, 2009 at 12:38 PM

Ok, I have found the issue.

Firstly, the SessionStateProvider class has a private field _client which is initialized at the field level as such: 

private MemcahcedClient _client = MemcachedClientService.Instance.Client;

It is never a good idea to do any initialization when implementing a Provider outside of the Initialize method as you will not get any debugging information, or in fact even be able to debug, due to the way ASP.NET copies and caches the types used as providers. Moving the client initialisation code into the Initialize block allowed me to debug and uncover the actual issue which was the <memcached enabled="true"> (enabled attribute) which is not supported. To be fair I got this config from the enyim project sample config file and not from this project, my bad.

Anyway it's all happy days now.